The difference between continue and break

  continue can be an unlabeled statement, which is used to terminate the current cycle of the current cycle, skip the remaining statements of the current cycle, and directly enter the next cycle of the current cycle. In a while or do while loop, an unlabeled continue statement causes the flow to jump directly to the conditional expression. The other is the continue statement without a label: continue label name. This label name should be defined before the outer loop statement in the program to identify the loop structure.

  The function of the break statement is to make the flow of the program jump out of a statement block, such as jumping out from the branch of the switch statement, or jumping out from the inside of the loop body. The break statement is divided into two types with labels and without labels. break Label name: The label name should be defined in front of the outer loop statement in the program to identify the loop structure. An unlabeled break statement jumps out of its switch branch or innermost loop body and executes the statement following the branch or loop body.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324644240&siteId=291194637