【发布时间】:2016-07-31 01:54:36
【问题描述】:
我有一个小代码可以在控制台中显示倒计时。
for(int i = this.roundTimerMinute; i > -1; i--)
{
for(int j = this.roundTimerSeconds; j > 0; j--)
{
if( j < 10)
{
System.out.println(i + ":0" + j);
}
else if(!(i == 0 && j == 60) && (j < 56 && i == 1))
{
System.out.println(i + ":" + j);
}
else if(i == 0 && j != 60)
{
System.out.println(i + ":" + j);
}
if(i == 0 && j == 60)
{
System.out.println("1:00");
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {}
}
}
目前的输出是这样的:
1:55
1:54
1:53
.
.
.
可以仅在一行中显示整个倒计时。不是连续的,但新的 println() 会像这样过度显示旧的:
1:55 (this display is overridden 1 seconds later by 1:54 and so on)
如果有任何帮助,我将不胜感激。 谢谢
法师
编辑:因此它可以与 /r 命令一起使用,但只能在 Windows 本身的 CMD 中使用。也许它是一个错误左右,但它回答了我的问题。谢谢你:)
【问题讨论】: