您的位置:首页 > 其它

No enclosing instance of type ThreadTest is accessible.错误解决

2014-08-10 21:23 731 查看
闲着学习了一下线程的知识,于是创建了一个类,跟着教材上敲了一下代码,结果在MyEclipse中出现了

No enclosing instance of type TestThread is accessible. Must qualify the allocation with an enclosing instance of type TestThread (e.g. x.new A() where x is an instance of TestThread).这样的错误提示,看看语义,翻译过来以后大概意思是:没有可访问的内部类TestThread的实例。百度了一下此项内容,大部分都是说类的动态和静态调用的问题,仔细看看原来是讲另一个类写在了main方法里面了,将其方法移出main方法之外出现以下情况
The public type Runner1 must be defined in its own file,至此问题很显然,原来需要另外new一个Runner1,将TestThread里面的Runner1删除就可以了,内中原理也一应明了,轻松解决。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐