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方法的啊,为什么还报那样的错误?

解决方案 »

  1.   

    import java.io.IOException;
    import java.io.InputStreamReader;
    public class test4 { 
    public static void main(String[] args) throws InterruptedException {  Thread.currentThread().sleep(1000); 
    System.out.println("hello");


    没报错啊
      

  2.   

    大哥那是警告,什么错误呀
    在方法前面添加
    @SuppressWarnings("static-access")
    要不直接
    使用Thread.sleep(1000); 
      

  3.   

    Thread.currentThread().sleep(1000); 是不是警告啊,应该不是错吧,他说的应该用static的方式去访问,是指类名.static方法名的方式
    改为Thread.sleep(1000);