No enclosing instance of type E is accessible.
No enclosing instance of type E is accessible.
静态方法(main)中调用内部类,会出现这样的问题;
学习了:https://www.cnblogs.com/runnigwolf/p/5570810.html
http://blog.csdn.net/sunny2038/article/details/6926079
public class SwingObserverExample {
public static void main(String[] args) {
JFrame jFrame = new JFrame();
JButton jButton = new JButton("Should I do it?");
jButton.addActionListener(new SwingObserverExample().new AngelListener());
jButton.addActionListener(new DevilListener());
jFrame.getContentPane().add(jButton);
jFrame.setVisible(true);
}
class AngelListener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Don't do it!");
}
}
static class DevilListener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Just do it!");
}
}
}
No enclosing instance of type E is accessible.的更多相关文章
- 【转】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 ...
- 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--转
原文:http://blog.csdn.net/sunny2038/article/details/6926079 最近在看Java,在编译写书上一个例子时,由于书上的代码只有一部分,于是就自己补了一 ...
- No enclosing instance of type test8 is accessible. Must qualify the allocation with an enclosing instance of type test8 (e.g. x.new A() where x is an
在编译一个例子时,结果编译时出现: No enclosing instance of type test8 is accessible. Must qualify the allocation wit ...
- No enclosing instance of type Outer is accessible. Must qualify the allocation with an enclosing instance of type Outer (e.g. x.new A() where x is an instance of Outer)
之前看内部类的时候没发现这个问题,今天写代码的时候遇到,写个最简单的例子: 下面这一段代码 红色的部分就是编译报错: No enclosing instance of type Outer is ac ...
- No enclosing instance of type Hello is accessible
1.static 关键字 修饰的成员被所有对象共享(包括成员变量和方法). 修饰的成员优先于对象存在. 存储于方法区(共享数据区)的静态区中. 静态方法只能访问静态成员. 静态方法中不可以使用this ...
- Java编译时出现No enclosing instance of type XXX is accessible.
今天在编译Java程序的时候出现以下错误: No enclosing instance of type Main is accessible. Must qualify the allocation ...
- No enclosing instance of type Test is accessible. Must qualify the allocation with an enclosing instance of type Test (e.g. x.new A() where x is an instance of Test).
Java编写代码过程中遇到了一个问题,main方法中创建内部类的实例时,编译阶段出现错误,查看错误描述: No enclosing instance of type Test is accessibl ...
- 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).
No enclosing instance of type Demo is accessible. Must qualify the allocation with an enclosing inst ...
随机推荐
- ueditor 编辑器,自定义图片上传
<div> <h1>完整demo</h1> <form method="post" name="form"> & ...
- 滴滴云安装mysql数据库
Linux CentOS安装配置MySQL数据库 没什么好说的,直接正面刚吧. 安装mysql数据库 a)下载mysql源安装包:wget http://dev.mysql.com/get/mys ...
- 是否可以从一个static方法内部发出对非static方法的调用
不可以.因为非static方法是要与对象关联在一起的,必须创建一个对象后,才可以在该对象上进行方 法调用,而static方法调用时不需要创建对象,可以直接调用.也就是说,当一个static方法被调用时 ...
- django 开发之给admin 模块添加富文本编辑器
第一步下载kindeditor http://kindeditor.net/demo.php 下载下来后放到静态文件static 下面的js下面 接着在admin 模块文章类下引入这富文本编辑器: ...
- java jar打包命令使用
用法:jar {ctxu}[vfm0Mi] [jar-文件] [manifest-文件] [-C 目录] 文件名 ... 选项: -c 创建新的存档 -t 列出存档内容的列表 -x 展开存档中的命名的 ...
- sass10 demo1
index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...
- zzulioj--1831-- 周末出游(vector建图+dfs)
1831: 周末出游 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 22 Solved: 8 SubmitStatusWeb Board Descr ...
- zzulioj--1828-- 贪心的小猫咪(贪心模拟)
1828: 贪心的小猫咪 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 14 Solved: 4 SubmitStatusWeb Board Des ...
- hdoj--1301--Jungle Roads(克鲁斯卡尔)
Jungle Roads Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...
- 洛谷P1137 旅行计划 解题报告(拓扑排序+DP)
我看了一下其他大佬的题解,大部分都是拓扑排序加上DP.那么我想有的人是不明白为什么这么做的,拓扑排序有什么性质使得可以DP呢?下面我就提一下. 对一个有向无环图(Directed Acyclic Gr ...