继承中子父类的静态代码块与构造方法的执行顺序

输出程序运行后的打印结果:

    class Father{
        static {
            System.out.print("1");
        }
        Father(){
            System.out.print("3");
        }
    }
    class Son extends Father{
        static {
            System.out.print("2");
        }
        Son(){
            System.out.print("4");
        }
        public static void main(String[] args) {
            Father s = new Son();
            s = new Son();
        }
    }

打印后的结果为:123434

原文地址:https://www.cnblogs.com/junlu/p/14222785.html