一起找bug

帮同学找的一个bug,错误代码如下:

 1 package dai_test;
 2 public class Test1 {
 3 
 4     public static void main(String[] args) {
 5         // TODO Auto-generated method stub
 6         MyThread myThread = new MyThread();
 7         myThread.setName("dai");
 8         myThread.start();
 9     }
10     class MyThread extends Thread{
11         public void run() {
12             super.run();
13              for(int i =0;i<10;i++){        
14                  System.out.println(  "Main.run()"+i+Thread.currentThread().getName()   );                
15           }
16         }
17     }
18 }

错误信息为第6行:No enclosing instance of type Test1 is accessible. Must qualify the allocation with an enclosing instance of type Test1 (e.g. x.new
 A() where x is an instance of Test1).

错误原因:将class MyThread写到了Class Text1里面。。。

posted @ 2016-01-21 21:07  鸡毛落一地  阅读(163)  评论(0编辑  收藏  举报