Java Continue
Java Continue Statement :
In Java, the continue statement is another control flow statement used within loops to alter the flow of execution. Unlike the break statement, which exits the loop entirely, continue is used to skip the remaining code inside the loop for the current iteration and move to the next iteration.
Usage of continue in Loops:
The continue statement is typically employed within loops (such as for, while, or do-while) to skip certain parts of the loop's code block and proceed directly to the next iteration.
Example using for loop:
Output:
In the example above, when i equals 2, the continue statement is triggered. It skips the remaining code inside the loop for that particular iteration and proceeds directly to the next iteration, in this case, i = 3.
The continue statement is useful for bypassing specific parts of a loop's code, allowing more precise control over loop execution based on certain conditions, without exiting the loop entirely.