class C{
static int count=0;
C(){
count++;
System.out.println("c constructor"+count);
}
}
class A{
static C c1=new C();
 C c2=new C(); A(int i){
System.out.println("a constructor "+(i+6));
}
}
class B extends A{
static C c3=new C();
C c4=new C();
static C c5=new C();
B(int i){
//super();
super(i);   // 次处的super(i)不是调用父类的构造方法么?那怎么没执行啊
c5=new C();
System.out.println("b constructor "+i);
} }class T7{
static A a1 = new A(1);
static B b1 = new B(2);
A a2= new A(3);
B b2 = new B(4);
C c6 = new C();
public static void main(String[] args){
System.out.println("begin");
T7 t = new T7();
System.out.println("end");
}}

解决方案 »

  1.   

    谁说没执行??
    super(10000);这样你输出看看!   
      

  2.   

    super(10000);这样你输出看看!   改为这样输出看
    看看有没有输出
    a constructor 10006的
      

  3.   

    class C{ 
    static int count=0; 
    C(){            //构造函数
    count++; 
    System.out.println("c constructor"+count); 

    } static C c1=new C(); //此时创建对象就调用了构造函数
     C c2=new C(); B(int i){ 
    //super(); 
    super(i);   // 次处的super(i)不是调用父类的构造方法么?那怎么没执行啊 
    c5=new C(); 
    System.out.println("b constructor "+i); 

    //因为B是继承自A的啊,super(i)调用的就是父类中的构造方法
      A(int i){ 
      System.out.println("a constructor "+(i+6)); 
      } 
    啊!