java中的this和super
this
对象本身。public class ThisTest {
ThisTest tTest;
public ThisTest(){
tTest = this;
}
public void test(){
System.out.println(this);
}
public static void main(String arg[]){
new ThisTest().test();
}
}
成员方法引用。
成员变量引用。public class ThisTest {
String name;
String password;
public ThisTest(String name,String password){
this.name = name;
this.password = password;
}
public static void main(String arg[]){
ThisTest tTest= new ThisTest("fanqd","123456");
System.out.println(tTest.name);
System.out.println(tTest.password);
}
}
在构造函数内部第一行,调用本类另一个构造函数。public class ThisTest {
String name;
String password;
public ThisTest(int age){
this("liulingling", "666666");
}
public ThisTest(String name,String password){
this.name = name;
this.password = password;
}
public static void main(String arg[]){
ThisTest tTest= new ThisTest(20);
System.out.println(tTest.name);
System.out.println(tTest.password);
}
}
Super
父类方法引用。
父类成员变量引用。
在构造函数第一行,调用父类构造函数。public class SuperTest extends Father {
public SuperTest(String name,int age){
super(name, age);
}
public SuperTest(){
super(); //可以省略,子类会自动调用父类的默认构造函数
}
public static void main(String arg[]){
SuperTest st = new SuperTest("fanqd",30);
System.out.println(st.name);
System.out.println(st.age);
SuperTest df = new SuperTest();
}
}
相关文档:
1.创建线程
方式一:通过Thread的子类创建,此时需要在Thread类的子类中重写父类的public void run()方法
方式二:直接使用Thread类创建
  ......
今天是学习OA系统的第一天,我对今天的上课内容做了简单的总结:
OA简介:
OA是OFFICE AUTOMATION的缩写,本意为利用技术的手段提高办公的效率,进而实现办公的自动化处理。采用Internet/Intranet技术,基于工作流的概念,使企业内部人员方便快捷地共享信息,高效地协同工作;改变过去复杂、低效的手工办公方式,实现迅速 ......
我今天学习了徐老师讲的ejb3的知识,我做了简单的笔记:
上午讲的是jpa的知识,下午讲的是EJB3的知识:
JPQL语句:hibernate的HQL语句一样。
简单查询:
Query query = em.createQuery("SELECT c from Customer c");
retur ......
66. EJB容器提供的服务
主要提供声明周期管理、代码产生、持续性管理、安全、事务管理、锁和并发行管理等服务。
67. EJB规范规定EJB中禁止的操作有哪些?
1.不能操作线程和线程API(线程API指非线程对象的方法如n ......
通过使用一些辅助性工具来找到程序中的瓶颈,然后就可以对瓶颈部分的代码进行优化。一般有两种方案:即优化代码或更改设计方法。我们一般会选择后者,因为不去调用以下代码要比调用一些优化的代码更能提高程序的性能。而一个设计良好的程序能够精简代码,从而提高性能。
下面将提供一些在JAVA程序的设计和编码中,为了能够 ......