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