public class Tst {
public static void main(String[] args) throws InterruptedException {
/*
* The static method sleep(long) from the type Thread should be accessed in a
* static way
*/
Thread.currentThread().sleep(1000);
}
}我明明就是用静态的方式访问sleep方法的啊,为什么还报那样的错误?
public static void main(String[] args) throws InterruptedException {
/*
* The static method sleep(long) from the type Thread should be accessed in a
* static way
*/
Thread.currentThread().sleep(1000);
}
}我明明就是用静态的方式访问sleep方法的啊,为什么还报那样的错误?
解决方案 »
- 求教 单列模式中延迟初始化和急切初始化的区别
- 在main方法中System.exit(0)与return 有什么区别???
- 有关:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
- 求教core java 10.7节
- JMF问题,悬赏100
- JBuilder紧急求救
- 《java 2 编程 21天自学通》清华出版社出的,是翻译的LAURA LEMAY ,ROGERS CADENHEAD 的原版,不知道这本书怎么样?
- 急急:高分请教:在applet中调用javascript函数出错:
- 学习java语言的请教。
- 送分64分:jbuilder5中用jdbc连不了本地数据库。
- invokeLater的调用顺序问题。比较简单的程序
- 改变JTextArea显示的颜色,不是全部变色啊?
import java.io.InputStreamReader;
public class test4 {
public static void main(String[] args) throws InterruptedException { Thread.currentThread().sleep(1000);
System.out.println("hello");
}
}
没报错啊
在方法前面添加
@SuppressWarnings("static-access")
要不直接
使用Thread.sleep(1000);
改为Thread.sleep(1000);