我有以下测试代码:
public class Main {
public static void main(String[] args) {
new Main();
}
public Main() {
int А = new Main2().А;
System.out.println(А);
}
public class Main2 {
public int A = 0;
}
}
运行时出现此错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
А cannot be resolved or is not a field
at Main.<init>(Main.java:10)
at Main.main(Main.java:6)
为什么我不能从它的外部类访问 Main2.A()?