原文:Java中出现No enclosing instance of type XXX is accessible问题

Java编写代码过程中遇到了一个问题,main方法中创建内部类的实例时,编译阶段出现错误,查看错误描述: Multiple markers at this line The value of the local variable test is not used No enclosing instance of type StaticCallDynamic is accessible. Must ...

2016-06-08 17:36 2 52299 推荐指数:

查看详情

Java变异出现错误:No enclosing instance of type XXX is accessible

摘要:写java代码时遇到下面的编译错误。 本文分享自华为云社区《Java中出现No enclosing instance of type XXX is accessible问题》,作者:zhushy 。 错误代码和错误现象 先记录下问题现象,写java代码时遇到下面的编译 ...

Sun Sep 26 19:43:00 CST 2021 0 103
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

之前看内部类的时候没发现这个问题,今天写代码的时候遇到,写个最简单的例子: 下面这一段代码 红色的部分就是编译报错: 根据提示,没有可以访问的实例Outer,必须分配一个合适的外部类实例以访问内部类。 正确的方式可以是: 或者: 关于内部类 依然是一个独立的类,在编译之后 ...

Sat Mar 05 06:55:00 CST 2016 1 2970
Javaxxx is not an enclosing class

1. 错误原因 该错误一般出现在对内部类进行实例化时,例如 此时B是A的内部类,如果我们要使用如下语句实例化一个B类的对象: A.B b = new A.B() 则会报错:B is not an enclosing class 2. 解决办法 方法一:若要 ...

Wed May 30 18:32:00 CST 2018 0 1098
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM