Four parts of the loop structure:
(1) Initial part: Set the initial state of the loop
(2) loop body: Repeated execution of code
(3) Iteration part: the part to be executed before the next cycle begins
(4) Cycle conditions: Determine whether to continue the cycle of conditions
For ( expression 1; expression 2; expression 3) {
Loop Body
}
for looping structure 3 meaning of the expression
An expression |
Form |
Function |
Example |
Expression 1 |
Assignment statements |
The initial part of the loop structure, assigning the initial value to the loop variable |
int i=0 |
Expression 2 |
Conditional statements |
Cyclic condition of cyclic condition loop structure of cyclic structure |
i<100 |
Expression 3 |
Assignment statements, usually using the + + or -- operator |
The iterative part of a looping structure, usually used to modify the value of a loop variable |
i++ |
Java supports 3 types of jumps: Break,continue, and return.
Break is used to terminate a loop so that the program jumps to the next statement outside the loop body. Statements that are in a loop after a break are no longer executed, and the loop also stops executing.
The difference between break and continue , in the loop structure:
The break statement is used to terminate a loop in which the program jumps to the next statement outside the loop body.
The Continue statement is a statement used to jump out of this loop and into the next loop.
Java's most basic three loop structures, while, Do-while, and for loop structures.
S1/using Java to understand program logic/06-loop Structure (ii)