类加载器
- 父类代码
public class Father { static { System.out.println("I am Father_static"); } public Father() { System.out.println("I am Father"); } }
子类代码
public class Childer extends Father{ static { System.out.println("I am Children_static"); } public Childer() { System.out.println("I am Childer"); } public static void main(String[] args) throws Exception { Father f =new Father(); Childer c =new Childer(); Father f1 =new Childer(); } }
console:
I am Father_static I am Children_static I am Father I am Father I am Childer I am Father I am Childer