public class AQuestion{
private int i = j;
private int j = 10;
public static void main(String args[]){
System.out.println((new AQuestion()).i);
}
}
1. Compiler error complaining about access restriction of private variables of AQuestion.
2. Compiler error complaining about forward referencing.
3. No error - The output is 0;
4. No error - The output is 10;
answer: 2
本文探讨了一段Java代码中出现的编译错误原因,包括私有变量访问限制及前向引用问题,并给出了正确的代码实现方式。

267

被折叠的 条评论
为什么被折叠?



