public class Z extends X {
Y y = new Y();
/**
* @param args
*/
Z(){
System.out.println("Z");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Z();
}
}
class X{
Y b = new Y();
X(){
System.out.println("X");
}
}
class Y{
Y(){
System.out.println("Y");
}
}
输出内容为什么?
答案:
Y
X
Y
Z