构造函数顺序

 1 class X
 2 {
 3     X()
 4     {
 5         System.out.println("x");            //2
 6     }    
 7     Y y=new Y();                            //1
 8 }
 9 class Y
10 {
11 
12     Y()
13     {
14         System.out.println("y");
15     }
16 }
17  class Z extends X{
18 
19     /**
20      * @param args
21      */
22      Y y=new Y();            //3
23     Z()
24     {
25         System.out.println("z");            //4
26     }
27     public static void main(String[] args)
28     {
29         // TODO Auto-generated method stub
30         new Z();
31     }
32 
33 }
View Code
原文地址:https://www.cnblogs.com/friends-wf/p/3581242.html