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();
}
}
相关文档:
这是clone技术介绍的第一篇。本篇主要介绍对象clone技术的基本知识。
Clone基本知识储备
在Java里提到clone技术,就不能不提java.lang.Cloneable接口和含有clone方法的Object类。所有具有clone功能的类都有一个特性,那就是它直接或间接地实现了Cloneable接口。否则,我们在尝试调用clone()方法时,将会触发CloneNo ......
我今天学习了徐老师讲的EJB3的知识,我做了简单的笔记:
SLSB无状态会话Bean的编程规则;
EJB类
编程规则
至少有一个业务接口
必须是具体类.不能是final或抽象的.
必须有空构造
可以是其它sessionbean或p ......
Impl
public class BaseDAOImpl extends HibernateDaoSupport implements IBaseDAO
//添加数据
this.getHibernateTemplate().save(achi);
//删除
this.getHibernateTemplate().delete(this.getById(achi));
//查询所有
return this.getHibernateTemplate().find("from Achievement a ......
通过使用一些辅助性工具来找到程序中的瓶颈,然后就可以对瓶颈部分的代码进行优化。一般有两种方案:即优化代码或更改设计方法。我们一般会选择后者,因为不去调用以下代码要比调用一些优化的代码更能提高程序的性能。而一个设计良好的程序能够精简代码,从而提高性能。
下面将提供一些在JAVA程序的设计和编码中,为了能够 ......
Java面试中,最常被人问到的几个问题:
1. java.util.*包的UML结构图。
2. Vector和ArrayList、LinkedList区别 Hashtable 和 HashMap之间的区别
3. String、StringBuffer,StringBuilder之间区别。
--回答--
1.
Collection
|
|_List
| |_LinkedList
| | ......