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).
2017-04-21 09:19
537 查看
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).
在练习一Demo时,遇到上面的编译时错误
原因:main是Test类的static方法,按照常理它只能访问Test类中static资源,而class A是非static所以报错了。
解决方法一:给class F添加static属性。
解决方法二: 没有必要把F放在Demo中做内部类,将它移到Demo外部地方定义。
相关文章推荐
- 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 E is accessible. Must qualify the allocation with an enclosing instance of type E(e.g. x.new A() where x is an
- No enclosing instance of type AddressDemo1 is accessible. Must qualify the allocation with an enclos
- java编译错误No enclosing instance of type TestFrame is accessible. Must qualify the allocation with an enclosing instance of type TestFrame (e.g. x.new A(
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosing instance of type SimpleT
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosi
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- 内部类的使用问题No enclosing instance of type Outer is accessible. Must qualify the allocation with an enclo
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java编译时出现 No enclosing instance of type Main is accessible. Must qualify the allocation with an encl
- No enclosing instance of type Outer is accessible. Must qualify the allocation with an enclosing ins
- 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
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instanc
- 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
- 使用内部类时提示No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosing instance of type SimpleT
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing