For loop
Grammar:
for (expression 1; expression 2; expression 3) {
Loop body
}
The for Operation step is
1 "2" 4 "3" 1 ...
Expression 1: Assignment statement > Initial part of loop structure, assigning initial value to loop variable,
Expression 2: Conditional statement > Looping condition of loop structure,
An expression 3 assignment statement, usually using the + + or--operator > Iteration portion of the loop structure, typically used to modify the value of a loop variable,
Continue statement vs. break statement:
The break statement is used to terminate a loop, and the program jumps to the next statement outside the loop body.
The continue statement is used to jump out of this loop and into the next loop statement.
While Do-while for three statement operation order comparison
While loop structure: The condition is judged first, and the loop body is executed. If the condition is not true, exit the loop.
Do-while Loop structure: First executes the loop body, in the condition judgment, the loop body executes at least once.
For loop structure: The initialization part is executed first, then the condition is judged, then the loop body is executed, and finally the iterative part is calculated. If the condition is not true, jump out of the loop.
Java Chapter Sixth