父子继承关系的各模块加载顺序记录

父类

public class Animal {static { System.out.println("Animal_static"); }{ System.out.println("Animal_block"); }public Animal() { System.out.println("Animal_Cons"); } }

子类
public class Dog extends Animal {static { System.out.println("Dog_static"); }{ System.out.println("Dog_bloc"); }public Dog() { System.out.println("Dog_cons"); }public static void main(String[] args) { Dog classOrder = new Dog(); } }

最终输出顺序
【父子继承关系的各模块加载顺序记录】Animal_static
Dog_static
Animal_block
Animal_Cons
Dog_block
Dog_cons

    推荐阅读