我是java新手,我正在尝试练习构建嵌套循环。
我想要以下打印结果:
it is now 00:00:00
it is now 00:00:01
it is now 00:00:02
it is now 00:00:03
...
it is now 11:59:59
所以你明白了。这是对超快时钟的愚蠢模拟
问题是它开始于:
it is now 10 : 55 : 46
it is now 10 : 55 : 47
it is now 10 : 55 : 48
...而不是 00 : 00 : 00
到目前为止,这是我的代码:
public class Example {
public static void main(String[] args)
{
int h = 0;
while(h<=11)
{
int m = 0;
while(m<=59)
{
for(int s=0; s<=59;s++)
{
System.out.println("it is now " + h + " : " + m + " : " + s );
}
m++;
}
h++;
}
}
任何帮助将不胜感激!西尔万