package com.bingo.frame.oop.cls;
class ClassA{
static int a = 100;
static {
System.out.println("ClassA.static{}");
}
}
class ClassB extends ClassA{
static {
System.out.println("ClassB.static{}");
}
}
//-XX:+TraceClassLoading
public class TestClassLoader07 {
public static void main(String[] args) {
//访问ClassA中的属性, ClassA主动加载
//ClassB被动加载, 被动加载不执行static初始化操作(JVM规范)
System.out.println(ClassB.a);
}
}
类的被动加载
最新推荐文章于 2022-11-23 14:30:40 发布