Java can';找不到符号睡眠(int)&;普林顿(国际)
我需要与Sleep()和printen()相关的帮助Java can';找不到符号睡眠(int)&;普林顿(国际),java,scite,Java,Scite,我需要与Sleep()和printen()相关的帮助 import java.util.*; 公开课范例 { 公共静态void main(字符串[]args) { int i=1; INTA=4; 而(i
import java.util.*;
公开课范例
{
公共静态void main(字符串[]args)
{
int i=1;
INTA=4;
而(i<4)
{
i++;
a——;
睡眠(1000);
System.out.println(“\t\t\t\t游戏开始于…”);
系统输出打印(“\t\t\t\t”+a);
}
}
}
我犯了错误
找不到符号
符号:方法睡眠(int)
地点:课堂示例
睡眠(1000)
请帮我解决这个问题import java.util.*;
import java.util.*;
public class example
{
public static void main(String[]args)
{
int i = 1;
int a = 4;
while( i < 4 )
{
i++;
a--;
try {
// thread to sleep for 1000 milliseconds
Thread.sleep(100);
} catch (Exception e) {
System.out.println(e);
}
System.out.println("\t\t\t\t The Game Begins In...");
System.out.print("\t\t\t\t " + a);
}
}
}
Output
The Game Begins In...
3 The Game Begins In...
2 The Game Begins In...
1
公开课范例
{
公共静态void main(字符串[]args)
{
int i=1;
INTA=4;
而(i<4)
{
i++;
a——;
试一试{
//线程睡眠1000毫秒
睡眠(100);
}捕获(例外e){
系统输出打印ln(e);
}
System.out.println(“\t\t\t\t游戏开始于…”);
系统输出打印(“\t\t\t\t”+a);
}
}
}
输出
游戏开始于。。。
游戏在……开始。。。
游戏开始于。。。
1.
我觉得自己像个编译器,我也找不到它们,它们应该是什么<代码>线程.睡眠(…)也许?那么,什么是printen
?!你认为这些方法是从哪里来的?我猜你的意思是println
,但是System.out.println
——我猜你的意思是Thread.sleep
。但是,我强烈建议在这一点上获得一本好的Java书籍或教程。堆栈溢出对于解决特定问题非常有用,但它不是学习语言基础知识的好方法。请阅读本网站的部分。如果有人给了你一个代码示例,当你尝试使用它时,它不起作用-他们可能是问这个问题的合适人选。很高兴你来了。
import java.util.*;
public class example
{
public static void main(String[]args)
{
int i = 1;
int a = 4;
while( i < 4 )
{
i++;
a--;
try {
// thread to sleep for 1000 milliseconds
Thread.sleep(100);
} catch (Exception e) {
System.out.println(e);
}
System.out.println("\t\t\t\t The Game Begins In...");
System.out.print("\t\t\t\t " + a);
}
}
}
Output
The Game Begins In...
3 The Game Begins In...
2 The Game Begins In...
1