我试图理解成员类在java中是如何工作的,但是当我尝试这段代码时
public class Class1 {
public static void main(String[] args) {
Class2 c = new Class2();
c.show();
}
class Class2 {
public void show() {
System.out.println("helloworld");
}
}
}
我收到此错误No enclosing instance of type Class1 is accessible. Must qualify the allocation with an enclosing instance of type Class1 (e.g. x.new A() where x is an instance of Class1)
,我无法理解原因!