Posted on 2009-05-29 16:12
☆ 阅读(308)
评论(0) 编辑 收藏 所属分类:
J2SM
package com.test;
public class OrderTest {
public static void main(String[] args) {
new Child();
new Child();
}
}
class Parent {
static {
System.out.println("parent static block");
}
public Parent() {
System.out.println("parent construct block");
}
}
class Child extends Parent {
static {
System.out.println("Child static block");
}
public Child() {
System.out.println("Child construct block");
}
}
执行顺序
1 父类的静态代码块
2 子类的静态代码块
3 父类的构造方法
4 子类的构造方法