本帖最后由 猪猪fly侠 于 2015-4-30 14:47 编辑
public class auther {
public static void main(String[] args) {
// TODO Auto-generated method stub
A a = new A(1,"abc");
}
}
class A{
int num;
String st;
A(){
System.out.println("无参构造");
}
A(int num){
this.num = num;
System.out.println("单参够着");
}
A(int num,String st){
this();
this.num = num;
this.st = st;
System.out.println("双参构造");
}
}
输出结果:
无参构造
双参构造。
|
|