题:JVM加载机制你知多少,是否真的知道,来猜猜这题的答案你就知道了。
不要太相信自己哦,猜完之后自己测试下(也可以回复博客让我来揭晓答案),大家给下第一映像的答案,顺便调查下。
================================================大胆给出你的答案==================================================
public class Test3_JVM {
static Test3_JVM test = new Test3_JVM();static int a = 0;
public Test3_JVM(){
a ++;
System.out.println(a + ":constructor");
}
public static void show(){
System.out.println(a + ":show");
}
public static void main(String[] args) {
Test3_JVM.show();
new Test3_JVM();
new Test3_JVM();
System.out.println(Test3_JVM.a);
System.out.println(Test3_JVM.a);
Test3_JVM.show();
}
}
================================================大胆给出你的答案==============================================
1:constructor
0:show
1:constructor
2:constructor
2
2
2:show