找不到符号 thread.sleep
could not find symbol thread.sleep
为什么我在这段代码中遇到错误,请帮助我。
出现错误
could not find symbol thread.sleep
代码如下:
import java.util.Date;
class Date_Time
{
public static void main(String[] args)
throws Throwable
{
while(true)
{
Date_Time d= new Date_Time();
System.out.print(d);
thread.sleep(500);
System.out.println("\r");
thread.sleep(500);
}
}
}
在Java中是大写的Thread.sleep(500);
。
Edit
Date_Time
是你的 class。如果要打印日期需要使用Date
library
Date d = new Date();
System.out.print(d);
d 是一个 class
,所以如果你打印一个 class 你会得到它的 tostring 表示,所以修改 class,(覆盖 toString 方法和 return 您需要从中获取的内容)
import java.util.Date;
class Date_Time{
public static void main(String[] args) throws Throwable {
while(true){
Date_Time d= new Date_Time();
System.out.print(new Date());
thread.sleep(500);
System.out.println("\r");
thread.sleep(500);
}
}
}
为什么我在这段代码中遇到错误,请帮助我。
出现错误could not find symbol thread.sleep
代码如下:
import java.util.Date;
class Date_Time
{
public static void main(String[] args)
throws Throwable
{
while(true)
{
Date_Time d= new Date_Time();
System.out.print(d);
thread.sleep(500);
System.out.println("\r");
thread.sleep(500);
}
}
}
在Java中是大写的Thread.sleep(500);
。
Edit
Date_Time
是你的 class。如果要打印日期需要使用Date
library
Date d = new Date();
System.out.print(d);
d 是一个 class
,所以如果你打印一个 class 你会得到它的 tostring 表示,所以修改 class,(覆盖 toString 方法和 return 您需要从中获取的内容)
import java.util.Date;
class Date_Time{
public static void main(String[] args) throws Throwable {
while(true){
Date_Time d= new Date_Time();
System.out.print(new Date());
thread.sleep(500);
System.out.println("\r");
thread.sleep(500);
}
}
}