【eclipse】No enclosing instance of type A is accessible. Must qualify the allocation with an enclosing instance of type A

时间:2023-03-10 01:29:04
【eclipse】No enclosing instance of type A is accessible. Must qualify the allocation with an enclosing instance of type A

用 eclipse 写 Java 代码时出现了这个问题,详细如下:

No enclosing instance of type TestParsingLinkedList is accessible. Must qualify the allocation with an enclosing instance of type TestParsingLinkedList (e.g. x.new A() where x is an instance of A).

其中 A 为类名。

原因:原来是静态方法中不能创建动态内部类的对象。

解决方法:将类改为 static, 或将方法改为非静态的。

参考:http://blog.****.net/sunny2038/article/details/6926079