Question:No enclosing instance of type MermoryGroup is accessible. Must qualify the allocation with an enclosing instance of type MermoryGroup (e.g. x.new A() where x is an instance of MermoryGroup).

No enclosing instance of type XXX is accessible_class

MermoryGroup为内部类,没有可访问的内部类MermoryGroup的实例,必须分配一个合适的内部类MermoryGroup的实例(如x.new A(),x必须是MermoryGroup的实例。)

内部类是动态的,也就是开头以public class开头。而主程序是public static class main。在Java中,类中的静态方法不能直接调用动态方法。只有将某个内部类修饰为静态类,然后才能够在静态类中调用该类的成员变量与成员方法。所以不做其他变动的情况下,最简单的解决办法是将public class改为public static class.

No enclosing instance of type XXX is accessible_class_02

No enclosing instance of type XXX is accessible_innert_03

或使用以下方式:

No enclosing instance of type XXX is accessible_class_04