Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
来源:互联网 发布:3d房屋设计软件 编辑:程序博客网 时间:2024/05/17 21:41
http://blog.csdn.net/sunny2038/article/details/6926079
这是不改动其他部分的解决方法。但是当我重新建一个java文件,再把那个类剪切到新建的java文件中去后,问题也解决了。
以上两个方法都不实用。最好办法如下:
No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instance of type E(e.g. x.new A() where x is an instance of E).
他的意思就是:没有任何类型 TestThread 的外层实例可访问。必须用类型 TestThread 的外层实例(例如,x.new A(),其中 x 是 TestThread 的实例)来限定分配。
例如:
public class CarTest { public class Car{ String engine; String Wheel; public void run(){ System.out.println("汽车在奔跑"); } } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //CarTest obj = new CarTest(); //Car car = obj.new Car(); //或者 <span style="background-color: rgb(255, 204, 0);"> Car car = new CarTest().new Car();</span> car.engine = "奇瑞"; car.run(); }} 运行测试:汽车在奔跑
问题完美解决。
0 0
- 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
- 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
- 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
- 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
- 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
- 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
- Web Server 架构浅谈-Simple Event-Driven Achitecture
- 音视频即时通讯开发
- 根据HiMi的写的android摇杆
- OpenGL学习笔记之法线向量
- 限制性与非限制性定语从句区别
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- 利用JDBC连接Oracle数据库
- requirejs初次接触
- Mustache.js前端模板引擎源码解读【一】
- Web Server 架构浅谈-Staged Event-Driven Achitecture(SEDA)
- HDOJ 题目1905 Pseudoprime numbers(快速幂)
- ScrollView can host only one direct child
- [ASP.NET MVC 大牛之路]03 - C#高级知识点概要(2) - 线程和并发
- SQL四种语言,DDL、DCL、TCL和DCL