import java.java.* 与import java.Date 的区别
import java.util.*;
public class TestInterrupt {
public static void main(String[] args) {
MyThread thread = new MyThread();
thread.start();
try {Thread.sleep(10000);}
catch (InterruptedException e) {}
thread.interrupt();
}
}
class MyThread extends Thread {
public void run(){
while(true){
System.out.println("==="+ new Date()+"===");
try {
sleep(1000);
} catch (InterruptedException e) {
return;
}
}
}
}
上面的程序编译的时候提示TestInterrupt.java:16: 找不到符号
符号: 构造函数 Date()
位置: 类 Date
System.out.println("==="+ new Date()+"===");
^
1 错误
但改为import java.util.Date;却能运行了
这是为什么?