sleep就是让程序睡眠,我们可以控制程序的运行时间,如下
我们在for循环里边加了个sleep, 执行一次睡眠一分钟, 这样就可以控制打印速度
public class test {
public static void main(String[] args) throws InterruptedException {
for (int i = 0; i < 30; i++) {
System.out.println(i);
Thread.sleep(1000);
}
}
}