Why we can not make an instance of inner class inside the main method of outer class in regular way?
问题 I know how to make an instance of an inner class. But I want to know why we can not do that in the following way: class outerclass{ public static void main(String[] args){ innerclass in=new innerclass(); } class innerclass{ } } If I do this then I get the following error: No enclosing instance of type outerclass is accessible. Must qualify the allocation with an enclosing instance of type outerclass (e.g. x.new A() where x is an instance of outerclass). Why? 回答1: class Demo{ public static