is not an enclosing class
public class A {
public class B {
}
};
需要实例B类时,按照正逻辑是,A.B ab = new A.B();
那么编译器就会出现一个错误–“is not an enclosing class”
再翻看相关的java代码,发现原来写法出错了!正确的做法是
A a = new A();
A.B ab = a.new B();
没有静态(static)的类中类不能使用外部类进行.操作,必须用实例来进行实例化类中类.
is not an enclosing class的更多相关文章
- 【转】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 A] – is not an enclosing class
public class A {public class B { }}; 需要实例B类时,按照正逻辑是,A.B ab = new A.B();那么编译器就会出现一个错误–“is not an encl ...
- 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 ...
- 【转】The final local variable xxx cannot be assigned, since it is defined in an enclosing type
文地址:http://blog.163.com/benben_long/blog/static/199458243201481102257544/ 本文就自己编程时候遇到的一个问题,简要描述一下,并提 ...
- 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错误提示is not an enclosing class
今天脑袋晕乎乎的,犯了个低级错误,好半天才反应过来 一直提示:is not an enclosing class 我居然把 RegisterActivity.class 写成了 RegisterAct ...
- Java编译时出现No enclosing instance of type XXX is accessible.
今天在编译Java程序的时候出现以下错误: No enclosing instance of type Main is accessible. Must qualify the allocation ...
随机推荐
- gvfs错误导致tilda和thunar启动缓慢问题的解决
tilda是一个非常轻便的下拉终端,但是安装之后启动发现要过十几秒才会出现界面.命令行启动发现报错如下: 用这条信息到处搜索也找不到有用的解答. 后来终于发现这是一个dbus超时的问题,虽然原因和这个 ...
- TCP为什么会采用三次握手,若采用二次握手可以吗?
建立连接的过程是利用C/S(客户机/服务器)模式,假设A为客户端,B为服务器端. TCP是采用三次握手进行连接的,简要说明该过程: (1) A向B发送连接请求 (2) B对收的的A的报文段进行确认 ( ...
- ini配置文件内如果有更新参数
ini配置文件内如果有更新参数 执行更新 更新参数 自动去下载执行????
- docker初学
Docker基础知识 1. Docker基础知识点 1.1 什么是Docker Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的.可移植的.自给自足的容器.(集装箱原理) 1.2 什 ...
- java8 Stream2
new Thread(() -> System.out.println("lambda表达式,取代匿名函数......")).start(); Stream.of(" ...
- 初识java-1.Java跨平台的原理
计算机只认识二进制的机器指令,而且不同的平台的计算机的机器指令不同.Java中将程序员编写的源码文件编译成字节码文件,在不同的计算机平台上安装不同的虚拟机,虚拟机将同一份字节码文件解释为不同的机器指令 ...
- 命令查看当前运行APP的包名和Activity
先用usb链接手机 启动要查看的程序,命令查看当前运行的包名和Activity更清晰. 使用adb shell dumpsys window | findstr mCurrentFocus 命令查看 ...
- 回炉Spring--Bean生命周期及AOP
Spring容器: 在基于Spring的应用中,你的应用对象生存于Spring容器(container)中,Spring容器负责创建对象,装配它们,配置它们并管理它们的整个生命周期,从生存到死亡.(在 ...
- tarjan-LCA模板
洛谷P3379 #include <cstdio> using namespace std; ; struct etype{ int t,next; }; struct qtype{ in ...
- 【LeetCode 75】颜色分类
题目链接 [题解] 维护一个左边界l和一个右边界r 其中0..l-1都是'0' 而 r+1..n-1都是'2' 我们令i=l;i<=r; 枚举每一个a[i]; ①如果a[i]=2.那么把a[i] ...