我在这个循环中犯了一些错误,我真的无法弄清楚。这里是循环:While循环问题:不会暂停
while (true) {
System.out.print(stepName[currentTick]);
for(int i = stepName[currentTick].length() - longestNameInt; i == 0; i--)
System.out.print(" ");
System.out.print(" [");
double percentCalc = (double) stepPercent[currentTick];
int slotsRep = (int) Math.round((percentCalc * 0.2));
for(int i = slotsRep; i == 0; i--)
System.out.print("*");
for(int i = 20 - slotsRep; i == 0; i--)
System.out.print(" ");
System.out.print("] " + stepPercent[currentTick] + "% \r");
if(currentTick == totalTicks)
break;
Thread.sleep(stepTime[currentTick]);
}
基本上,它只是保持打印'(第一stepname)[*] 0%'迅速。 对不起,如果它是超级明显的,但我有点菜鸟。 :)
P.S.请问我是否需要更多的课程。
您能否提及当前tick和totalticks的预期值,可能会发生这样的情况:他们将会破坏并且您的环路变得无限 – Prateek
如果任何解决方案解决您的问题而不是接受SO上的答案。 – Prateek