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 ...
随机推荐
- Django组件——Cookie与session相关
一,会话跟踪技术 1 什么是会话跟踪技术我们需要先了解一下什么是会话!可以把会话理解为客户端与服务器之间的一次会晤,在一次会晤中可能会包含多次请求和响应.例如你给10086打个电话,你就是客户端,而1 ...
- css3 清除浮动
eg:三个div,父级div下面有两个div分别float:left和float:right <style> .container{width:400px;border:3px soild ...
- Nginx环境部署
下载Nginx wget nginx.tar.gz http://nginx.org/download/nginx-1.17.1.tar.gz 解压源码 tar -zxvf nginx-1.17.1. ...
- HashMap、HashTable、ConcurrentHashMap区别
HashMap与HashTable区别 HashMap与ConcurrentHashMap区别 1.HashMap与HashTable的区别 HashMap线程不安全,HashTable线程安全 Ha ...
- 08.@Scheduled定时任务、整合jdbcTemplate、mybatis区分多数据源
@Scheduled注解执行定时任务 import org.springframework.scheduling.annotation.Scheduled; import org.springfram ...
- Linux基础优化(二)
Linux基础优化(二) 一操作系统字符优化 避免出现中文乱码,UTF-8支持中文GBK-Xx支持中文 (一)查看默认编码 [root@centos7 ~]# echo $LANG en_US.UTF ...
- IO操作之ObjectInputStream与ObjectOutputStream
之前写过DataInputStream和DataOutputStream,使用这两个类可以对java基本数据类型进行序列化和反序列化. 本篇再来两个新东西:ObjectInputStream,Obje ...
- 'Error Domain=NSURLErrorDomain Code=-999' AFNetworking请求报错
早上请求app请求登录接口发现了下面的错误信息: Error Domain=NSURLErrorDomain Code=-999 "已取消" UserInfo={NSErrorFa ...
- 如何为网站启用HTTPS加密传输协议
前言 当今时代对上网的安全性要求比以前更高,chrome和firefox也都大力支持网站使用HTTPS,苹果也从2017年开始在iOS 10系统中强制app使用HTTPS来传输数据,微信小程序也是要求 ...
- python 对 excel 的操作
参考:https://www.php.cn/python-tutorials-422881.html 或 https://blog.51cto.com/wangfeng7399/2339556(使用 ...