loop statement in java

1. Overview of loop statements in java: There are three types of loop statements in java: for loop statement, do while statement, while statement.
2. The detailed introduction and difference of the three kinds of loop statements: 1) The structure of the for loop statement: for (expression 1; expression 2; expression 3) {loop body} The execution order is: expression 1 - expression 2 --loop body --expression3 --expression2 --loop body......
                                                      2) The role of each expression in the for loop statement: expression 1 is the initialization of the loop variable, and expression 2 is the control of the loop condition
Expression 3 is the assignment of the loop variable;
                                                      3) The structure and difference between do while statement and while statement: do {loop body}while(expression);while(expression){loop body}; do while statement is executed first and then judged, so its loop body is executed at least once ;The while statement is judged first and then executed, so its loop body may not be executed once;
3. Break continue in the loop statement return: break directly ends the current loop, continue ends the current loop and enters the next loop, and return ends the operation of the entire method;                               

Guess you like

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