超级高超,超级郁闷,超级难的超级JAVA问题
public class Test {
static Test test = new Test();
public Test(){
System.out.println("haha");
}
public static void main(String[] args){
Test test = new Test();
}
}
输出的居然是haha
haha
public class Test {
Test test = new Test();
public Test(){
System.out.println("haha");
}
public static void main(String[] args){
Test test = new Test();
}
}
不能运行
public class Test {
static Test test = new Test();
public Test(){
System.out.println("haha");
}
}
输出一个haha后,出现错误提示。
超级郁闷啊,请大家分析以下JAVA的运行机制,为什么会出现上面哪些情况的啊,谢谢大家啊