Java 找不到符号thread.sleep
为什么我在这个代码中遇到错误请帮助我。 错误就要来了 找不到符号thread.sleep 代码如下:Java 找不到符号thread.sleep,java,compiler-errors,cannot-find-symbol,Java,Compiler Errors,Cannot 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()
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.sleep500;大写字母
编辑
日期和时间是你的课。如果要打印日期,需要使用日期库
d是一个类,因此如果您打印一个类,您将获得它的tostring表示,因此修改该类,重写tostring方法并从中返回您需要的内容
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);
}
}
}
你为什么大喊大叫???应该是线程;谢谢,但是在用T代替T之后,我没有以正确的方式得到o/p,这很糟糕1@bedef2...are你想每秒打印一次实际日期吗?看看我的post@MohammadAdil谢谢你,但能告诉我我这个代码哪里错了吗?谢谢,但是在用T代替T之后,我没有以正确的方式得到o/p,很快就来了1@bedef2...@ShakhKhan你希望看到什么?时间和日期我希望它显示当前的日期和时间,但有些不同已导入日期包..mah程序第1行检查。。
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);
}
}
}