/** * Created by Administrator on 2017/3/6. */ /** * @author zhenghong * @date 2017-03-06-22:07 **/public class TestA { public static void main(String []args) { new B(); }}class A{ static { System.out.println("static A"); } public A() { System.out.println("constutor A"); } { System.out.println("normal A"); }}class B extends A{ static { System.out.println("static B"); } { System.out.println("normal B"); } public B() { System.out.println("constutor B"); }} 结果
static A
static B
normal A
constutor A
normal B
constutor B
结论,父类静态--》子类静态--》父类代码块--》父类构造函数--》子类代码块--》子类构造函数
时间: 2024-10-12 13:35:02