Java错误:No enclosing instance of type MyClass is accessible.
来源:互联网 发布:昂酷拍卖系统源码 编辑:程序博客网 时间:2024/06/08 01:01
No enclosing instance of type MyClass is accessible. 今天在练习Java时遇到了这个错误,百度后,觉得那篇博客说得很好,于是,准备偷过来。
下面是作者所说的:根据提示,没有可访问的内部类E的实例,必须分配一个合适的内部类E的实例(如x.new A(),x必须是E的实例);
原来我写的内部类是动态的,也就是开头以public class开头。而主程序是public static class main。在Java中,类中的静态方法不能直接调用动态方法。只有将某个内部类修饰为静态类,然后才能够在静态类中调用该类的成员变量与成员方法。所以在不做其他变动的情况下,最简单的解决办法是将public class改为public static class.
重点是:在Java中,类中的静态方法不能直接调用动态方法。只有将某个内部类修饰为静态类,然后才能够在静态类中调用该类的成员变量与成员方法。
0 0
- Java错误:No enclosing instance of type MyClass is accessible.
- No enclosing instance of type ThreadTest is accessible.错误解决
- No enclosing instance of type * is accessible.
- No enclosing instance of type is accessible.
- Java出现No enclosing instance of type E is accessible
- Java出现No enclosing instance of type E is accessible 错误
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the alloc
- java错误提示------No enclosing instance of type Demo10_1 is accessible
- JAVA编译错误 “No enclosing instance of type XXX is accessible”的解决方法
- Java出现No enclosing instance of type FilenameFileterTest is accessible.编译错误
- Java错误No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosing instance of type SimpleTh
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosing instance of type SimpleTh
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosing instance of type SimpleTh
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosing instance of type SimpleT
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosing instance of type SimpleTh
- 【JAVA001】No enclosing instance of type XXX is accessible.
- No enclosing instance of type E is accessible
- Linux free命令详解
- jhipster安装与使用
- mysql定时任务
- 【软件测试】验收测试
- 数据库查询 带参的两种方式
- Java错误:No enclosing instance of type MyClass is accessible.
- jpg转pdf在线转换方法速成
- ldd3 运行脚本awk
- 关于iOS基础总结(7)--ios各个版本新特性总结
- API Blueprint笔记
- apache http server用户认证
- (OK) Linux 下解包华为固件包UPDATE.APP
- 字符集编码的文本文件头标识
- VS2010 使用TeeChart绘图控件 - 之一 - 控件和类的导入