[java]代码库
class AA{
String name;
public AA(String name){
this.name=name; //如果不写this那肯定出错编译都通不过.
}
} //源代码片段来自云代码http://yuncode.net
class AA {
String name;
public AA(){
System.out.println("1无参构造.....");
}
public AA(String name){
this();
this.name=name;
System.out.println("2有参构造....."+name);
}
public static void main(String[] args) {
AA a = new AA("author");
}
} //源代码片段来自云代码http://yuncode.net
class AA {
String name;
public AA(){
System.out.println("1无参构造.....");
System.out.println(this); // 打印的是对象a的内存地址.
}
public void play(){
System.out.println("游戏人生........");
}
public static void main(String[] args) {
AA a = new AA();
}
} //源代码片段来自云代码http://yuncode.net