public class OrderTest {
public static void main(String[] args) {
new Child();
}
}
class Parent {
static String name = "hello";
static {
System.out.println("Parent static");
}
public Parent() {
System.out.println("Parent constructor");
}
}
class Child extends Parent {
static String childName = "world";
static {
System.out.println("Child static");
}
public Child() {
super();
System.out.println("Child constructor");
}
}
结果
Parent static
Child static
Parent constructor
Child constructor
网友评论