且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java的while循环中的continue语句导致无限循环

更新时间:2022-01-11 03:27:36

conitnue,将返回while循环.并且taskToDo的递减永远不会超过2.

conitnue, will go back to the while loop. and tasksToDo will never get decremented further than 2.

var tasksToDo = 3
while (tasksToDo > 0) {
if (tasksToDo == 2) {
 tasksToDo--;             // Should be here too.
 continue;
}

console.log('there are ' + tasksToDo + ' tasks');
tasksToDo--;
}