Open yeziarrietty opened 3 weeks ago
When a break statement is executed in a loop (for or while), it immediately terminates the loop it is currently in. The execution process of the program will jump out of the loop and continue to execute the statements that follow the loop.
When the continue statement is executed in a loop, it skips the remaining blocks of code in the current loop iteration and starts the next iteration of the loop. That is, the loop will not be terminated, but the subsequent code in the current round of the loop will not be executed. In short, the break statement will terminate the loop early, and the continue statement will stop the loop and move on to the next loop.
What is the difference betweenbreakandcontinuestatements in a loop?