为什么main方法中无法实例化非静态内部类
时间:2010-07-17 来源:dracularking
No enclosing instance of type close is accessible. Must qualify the allocation with an enclosing instance of type close (e.g. x.new A() where x is an instance of close).
对main方法而言,它是游离于任何类之外的,因此某类的非静态内部类对它而言是不直接可见的,也就无法直接访问,like this:
enclosingInstance = new EnclosingClass();
nestedInstance = enclosingInstance.new NestedClass();
相关阅读 更多 +