标签:git nal 创建 初始 初始化 通过 ble code const
SuperClass类:
public class SuperClass {
public static String staticVariable = "staticVariable";
public static final String STATIC_CONSTANT = "STATIC_CONSTANT";
static {
System.out.println("SuperClass is loading.");
}
}
现有一段代码,创建了SuperClass数组:
public class MainClass {
static {
System.out.println("MainClass is loading.");
}
public static void main(String[] args) {
SuperClass[] superClasses = new SuperClass[3];
}
}
上述代码执行后,控制台输出:
MainClass is loading.
可见,通过数组定义来引用类,并不会触发类的初始化。
标签:git nal 创建 初始 初始化 通过 ble code const
原文地址:https://www.cnblogs.com/XiaoZhengYu/p/13194843.html