关于构造函数的执行顺序?
cyxyz 2005-10-31 10:59:21 class Parent {
Parent() {System.out.println("xxxxx");}
Parent(int i) {System.out.println(i); }
}
class Child extends Parent {
Child() {
super(1);
}
}
class AA{
public static void main(String args[])
{
new Child();}}
结果只显示1。为什么?
书上不是说如果子类自己定义了构造函数,则在创建新对象时先执行继承父类的无参构造函数,然后再执行自己的构造函数吗??