No enclosing instance of type Monster is accessible. Must qualify the allocation with an enclosing i
2012-07-14 19:55
453 查看
错误提示:No enclosing instance of type Monster is accessible. Must qualify the allocation with an enclosing instance of type Monster (e.g. x.new A() where x is an instance of Monster).
于是百度谷歌了一下相关资料。原来我写的内部类是动态的,也就是开头以public class开头。而主程序是public static class main。在Java中,类中的静态方法不能直接调用动态方法。只有将某个内部类修饰为静态类,然后才能够在静态类中调用该类的成员变量与成员方法。所以解决办法是将public class改为public static class.
于是百度谷歌了一下相关资料。原来我写的内部类是动态的,也就是开头以public class开头。而主程序是public static class main。在Java中,类中的静态方法不能直接调用动态方法。只有将某个内部类修饰为静态类,然后才能够在静态类中调用该类的成员变量与成员方法。所以解决办法是将public class改为public static class.
相关文章推荐
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instanc
- 错误提示:No enclosing instance of type A is accessible. Must qualify the allocation with an enclosing
- No enclosing instance of type Demo is accessible. Must qualify the allocation with an enclosing instance of type Demo (e.g. x.new A() where x is an instance of Demo).
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type H is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- 【eclipse】No enclosing instance of type A is accessible. Must qualify the allocation with an enclosing instance of type A
- No enclosing instance of type B is accessible. Must qualify the allocation with an enclosing ins (20
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing insta
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing--转
- Java错误No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- No enclosing instance of type A is accessible. Must qualify the allocation with an enclosin
- Java出现No enclosing instance of type Test is accessible. Must qualify the allocation with an enclosin
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing[转]