public class AbcXyz {
W w = new W();
public static void main(String[] args) {
new Z();
}
}
class W {
{
System.out.println("W的构造代码块......10");
}
static {
System.out.println("W的静态代码块......9");
}
W() {
System.out.println("W的空参构造函数....11");
}
}
class Y {
{
System.out.println("Y的构造代码块.....4");
}
static {
System.out.println("Y的静态代码块.....3");
}
Y() {
System.out.println("Y的空参构造函数....5");
}
}
class X {
Y b = new Y();
{
System.out.println("X的构造代码块.....6");
}
static {
System.out.println("X的静态代码块.....1");
}
X() {
System.out.println("X的空参构造函数....7");
}
}
public class Z extends X {
{
System.out.println("Z的构造代码块......8");
}
static {
System.out.println("Z的静态代码块......2");
}
Z() {
super();
System.out.println("Z的空参构造函数....12");
}
}
|
|