您的位置:首页 > 其它

解决 e.g. x.new A() where x is an instance of xxx.class

2016-02-25 11:17 387 查看
No enclosing instance of type xxx.class(你的类) is accessible. Must qualify the allocation with an enclosing instance of type xxx.class(你的类) (e.g. x.new A() where x is an instance of xxx.class(你的类)).

出现以上错误的原因:

public class One{

public static void main(String []args){

Two mTwo= new Two();

}

class Two{

}

}


注意你以上的方括号,在类One中,是包括Two类的,所以会出现以上的报错。

解决方法为:

public class One{

public static void main(String []args){

Two mTwo = new Two();

}

}
class Two{

}


把Two移除One类即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  instance class