public class A {
public class B {
}
};
实例化B类时,写成了 A.B ab = new A.B();
编译器报错–“is not an enclosing class”
正确的写法是:
A a = new A();
A.B ab = a.new B();
没有静态(static)的类中类不能使用外部类进行.操作,必须用实例来进行实例化类中类
public class A {
public class B {
}
};
实例化B类时,写成了 A.B ab = new A.B();
编译器报错–“is not an enclosing class”
正确的写法是:
A a = new A();
A.B ab = a.new B();
没有静态(static)的类中类不能使用外部类进行.操作,必须用实例来进行实例化类中类