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.的更多相关文章

  1. 【转】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 ...

  2. 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   ...

  3. 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,在编译写书上一个例子时,由于书上的代码只有一部分,于是就自己补了一 ...

  4. 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 ...

  5. 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 ...

  6. No enclosing instance of type Hello is accessible

    1.static 关键字 修饰的成员被所有对象共享(包括成员变量和方法). 修饰的成员优先于对象存在. 存储于方法区(共享数据区)的静态区中. 静态方法只能访问静态成员. 静态方法中不可以使用this ...

  7. Java编译时出现No enclosing instance of type XXX is accessible.

    今天在编译Java程序的时候出现以下错误: No enclosing instance of type Main is accessible. Must qualify the allocation ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. [HNOI2015]亚瑟王(期望+DP)

    题解 利用期望的线性性,可以把问题转化为求每一个卡牌造成期望的期望值. 然后我们就需要知道每一个卡牌发动技能的概率. 因为当某一张卡牌发动技能时这一轮会结束,这就很难直接计算了. 我们使用DP 设dp ...

  2. 搭建rsync实时同步

    1.本实验基于centos6.5服务器做的 cat cat /etc/redhat-release 2.在配置环境之前需要先将服务器自带的rsync卸除 yum -y remove rsync* 3. ...

  3. 洛谷 P1417 烹调方案 (01背包拓展)

    一看到这道题就是01背包 但是我注意到价值和当前的时间有关. 没有想太多,直接写,0分 然后发现输入方式不对-- 改了之后只有25分 我知道wa是因为时间会影响价值,但不知道怎么做. 后来看了题解,发 ...

  4. [HAOI2009]毛毛虫(树形dp)

    [HAOI2009]毛毛虫 题目描述 对于一棵树,我们可以将某条链和与该链相连的边抽出来,看上去就象成一个毛毛虫,点数越多,毛毛虫就越大.例如下图左边的树(图 1 )抽出一部分就变成了右边的一个毛毛虫 ...

  5. Object-C,NSSet,不可变集合

    又到晚上了,继续码代码. 正在此时,老爸一个电话"海阔凭鱼跃,天高任鸟飞",老爸不在为老问题烦我了. 自由了,突然感觉压力好大啊. 将来混的太惨,可咋办啊- 第1个例子是,不可变集 ...

  6. POJ——T 3687 Labeling Balls

    http://poj.org/problem?id=3687 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 14842   ...

  7. 10个关于Android开发的实用教程

    本文为致力于Android应用的开发人员精选了几个不错的实用教程,无论是初学者还是专业开发人员都应该能够从中获益.这些教程中有不少是关于绘图和地址服务运用的,另外一些则是SDK相关的.希望对大家有所帮 ...

  8. hihocoder 1124 : 好矩阵 dp

    好矩阵 时间限制:3000ms 单点时限:1000ms 内存限制:256MB 描写叙述 给定n, m.一个n × m矩阵是好矩阵当且仅当它的每一个位置都是非负整数,且每行每列的和 ≤ 2.求好矩阵的个 ...

  9. STL_算法_查找算法(binary_search、includes)

    C++ Primer 学习中.. . 简单记录下我的学习过程 (代码为主) 全部容器适用(O(log(n)))     已序区间查找算法 binary_search             //二分查 ...

  10. Android 取得 ListView中每个Item项目的值

    首先我们须要创建 ListView .这里假定我们已经创建好了而且使用SimpleAdapter设置好了adapter数据,看一下我们的adapter ArrayList<HashMap< ...