The static method currentThread() from the type Thread should be accessed in a static way用静态方式存取 怎么操作?public static void main(String[] args){ Thread worker=new Thread(); String name = worker.currentThread().getName(); System.

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/15 02:13:03
ThestaticmethodcurrentThread()fromthetypeThreadshouldbeaccessedinastaticway用静态方式存取怎么操作?publicstaticv

The static method currentThread() from the type Thread should be accessed in a static way用静态方式存取 怎么操作?public static void main(String[] args){ Thread worker=new Thread(); String name = worker.currentThread().getName(); System.
The static method currentThread() from the type Thread should be accessed in a static way
用静态方式存取 怎么操作?
public static void main(String[] args){
Thread worker=new Thread();
String name = worker.currentThread().getName();
System.out.println(name);
}
其中 worker.currentThread() 出现该警告.

The static method currentThread() from the type Thread should be accessed in a static way用静态方式存取 怎么操作?public static void main(String[] args){ Thread worker=new Thread(); String name = worker.currentThread().getName(); System.
它指的是currentThread()方法是个静态方法,用静态方式去访问,不是类的实例去调用.
你可以不管它,或者用Thread.currentThread().getName();