java编译错误:
No enclosing instance of type Classname is accessible. Must qualify the allocation with an enclosing instance of type Classname(e.g. x.new A() where x is an instance of Classname).
原因:
成员内部类创建之前,必须先创建外部类。
形如:
public class outclass{
public class innerclass{
}
}
想要使用类innerclass,必须先创建外部类。
方法:
outclass out=new outclass();
out.innerclass inner=out.new innerclass();