No enclosing instance of type XXX is accessible
2017-12-25 16:22
381 查看
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).
MermoryGroup为内部类,没有可访问的内部类MermoryGroup的实例,必须分配一个合适的内部类MermoryGroup的实例(如x.new A(),x必须是MermoryGroup的实例。)
内部类是动态的,也就是开头以public class开头。而主程序是public static class main。在Java中,类中的静态方法不能直接调用动态方法。只有将某个内部类修饰为静态类,然后才能够在静态类中调用该类的成员变量与成员方法。所以在不做其他变动的情况下,最简单的解决办法是将public class改为public static class.
或使用以下方式:
相关文章推荐
- Java在编译运行时出现No enclosing instance of type XXX is accessible问题
- Java中出现No enclosing instance of type XXX is accessible问题
- Java中出现No enclosing instance of type XXX is accessible问题
- 解决android出现static void xxx No enclosing instance of type xxx is accessible
- Java编译时出现No enclosing instance of type XXX is accessible.
- No enclosing instance of type xxx is accessible
- No enclosing instance of type XXX is accessible
- 验证参数传递引发的Java编译错误“No enclosing instance of type XXX is accessible" 及匿名内部类
- JAVA编译错误 “No enclosing instance of type XXX is accessible”的解决方法
- java解决 No enclosing instance of type XXX is accessible的问题
- Java中出现No enclosing instance of type XXX is accessible问题
- 【JAVA001】No enclosing instance of type XXX is accessible.
- Java中出现No enclosing instance of type XXX is accessible问题
- No enclosing instance of type XXXis accessible. Must qualify the allocation ....
- No enclosing instance of type xxx is accessible 问题及解答,静态方法调用动态方法问题
- Java中出现No enclosing instance of type XXX is accessible问题
- <java>No enclosing instance of type GraphicFrame is accessible. Must qualify the allocation with an
- Java出现No enclosing instance of type E is accessible 错误
- java编译错误处理No enclosing instance of type demo1_1 is accessible.
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing