2007-11-04

容易出错的Java题

关键字: 原创,个人积累

1、下面代码
class TestThread extends Thread{
 public static void main(String[] args)
 {
  TestThread th=new TestThread();
  th.start();
 }
 
 public void start()
 {
  System.out.println("start");
 }
 
 public void run()
 {
  System.out.println("run");
 }
}
输出:start。 public void start()将Thread中的start()方法重写了,不会去调用run方法。

评论
发表评论

您还没有登录,请登录后发表评论

younker
搜索本博客
最近加入圈子
存档
最新评论