class Father{
Father(){
System.out.print("这是父类输出\n");
}
}public class Son extends Father{
Son(){System.out.print("这是子类输出");}
Son(boolean a){
this();
super();
}
public satic void main(String args[]){
new Son(true);
}
}
Father(){
System.out.print("这是父类输出\n");
}
}public class Son extends Father{
Son(){System.out.print("这是子类输出");}
Son(boolean a){
this();
super();
}
public satic void main(String args[]){
new Son(true);
}
}
2.Son(boolean a){
this();
super();
}
这个构造函数有问题,不能在里面同时调用2个构造函数,因为构造函数的调用必须放在第一行,你既要调用子类的构造又要调父类的构造就会产生冲突,因为重要有一个放在第二行.
class Father{
Father(){
System.out.print("这是父类输出\n");
}
}可是我public class Son extends Father{
Son(){
super();
System.out.print("这是子类输出");}
Son(boolean a){
this();
}
public static void main(String args[]){
new Son(true);
}
}用jdk1.5.0_16,winxp sp3D:\6>java Son
╒Γ╩╟╕╕└α╩Σ│÷
╒Γ╩╟╫╙└α╩Σ│÷
D:\6>不知为什么出现了
乱码
所以错一点也不好找