类加载器—面试总结

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/zou229752401/article/details/79435202

类加载器

  • 父类代码
  • 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
    
展开阅读全文

没有更多推荐了,返回首页