The sequential structure of a program statement can only be executed once. If you want the same operation to execute multiple times, you need to use the loop structure.
There are three main loop structures in Java:
- While loop
- Do...while Cycle
- for Loop
An enhanced for loop that is primarily used in arrays is introduced in Java5.
The break keyword
Break is used primarily in loop statements or switch statements to jump out of the entire block of statements.
Break jumps out of the innermost loop, and continues execution of the statement below the loop.
Continue keywords
The Continue is suitable for any loop control structure. The function is to let the program jump immediately to the next iteration of the loop.
In the For loop, the continue statement causes the program to jump immediately to the UPDATE statement.
In the while or Do...while loop, the program immediately jumps to the judgment statement of the Boolean expression.
JAVA looping structure-for, while and Do...while