ConWithThis
public class ConWithThis {
int count=0;
String str="hello";
ConWithThis(int i){
this("java");
count=i;
System.out.println("Constructor with int arg only,count="+count);
}
ConWithThis(String s){
this(i);
this.str=s;
System.out.println("Constructor with String arg only,s="+s);
}
ConWithThis(String s,int i){
this(i);
this.str=s;
System.out.println("Constructor with String and int args,s="+s+",i="+i);
}
ConWithThis(){
this("use this reference",9);
System.out.println("default constructor(no args)");
}
void f(){
System.out.println("count="+count+",s="+str);
}
public static void main(String[] args) {
// TODO 自动生成的方法存根
ConWithThis x=new ConWithThis();
x.f( );
}
}