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 ...
随机推荐
- The Structure of an App-ios应用架构-MVC
During startup, the UIApplicationMain function sets up several key objects and starts the app runnin ...
- CF666E Forensic Examination 广义后缀自动机_线段树合并_树上倍增
题意: 给定一个串 $S$ 和若干个串 $T_{i}$每次询问 $S[pl..pr]$ 在 $Tl..Tr$ 中出现的最多次数,以及出现次数最多的那个串的编号. 数据范围: 需要离线 题解:首先,很常 ...
- springMVC 定时器配置
1.在springMVC中加入 xmlns:task="http://www.springframework.org/schema/task" http://www.springf ...
- dropload上拉加载 下拉刷新
1.引入css.js <link rel="stylesheet" href=" ${pageContext.request.contextPath}/dist/d ...
- 使用systemctl自定义系统服务
1.创建系统服务文件,格式如下: [Unit] Description=httpd After=network.target [Service] Type=forking ExecStart=/usr ...
- vue.js的<slot>
使用插槽分发内容在封装vue组件的时候,很多时候就不得不使用到vue的一个内置组件<slot>.slot是插槽的意思,顾名思义,这个<slot>组件的意义是预留一个区域,让其中 ...
- 在pycharm中配置Anaconda以及pip源配置
在学习推荐系统.机器学习.数据挖掘时,python是非常强大的工具,也有很多很强大的模块,但是模块的安装却是一件令人头疼的事情. 现在有个工具--anaconda,他已经帮我们集成好了很多工具了!an ...
- 6、python中的字符串
最早的编码为ascii码,共256个符号.UTF-8是国际通用编码,全面支持中文,以一个字节表示英文,以三个字节表示一个中文以及其他语言:GB2312是我国自己定制的中文编码标准,使用1个字节表示英文 ...
- ,典型递归问题-F(1025)mod 5 的值
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/ ...
- delphi网络函数大全
{=========================================================================功 能: 网络函数库时 间: 2002/10/02版 ...