您的位置:首页 > 其它

No enclosing instance of type X is accessible. Must qualify the allocation with an enclosing instanc

2016-01-11 19:12 330 查看
No enclosing instance of type X is accessible. Must qualify the allocation with an enclosing instance of type X(e.g.  x.new A() where x is an instance of X)

写代码时一直包这个错误,也没有在意,第一次查了下资料找到原因了,就算了!可后面有出现一次,所以一定要记下来!

这个的原因是内部类的问题,如果你的主类(MainClass)是static,那么你的内部类也必须是static,好比静态方法中调用的全局变量也必须是静态的一样!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: