The format is:
It ends the current loop of the loop statement and executes the next loop.
Statements after the continue statement are ignored, and execution control jumps to the beginning of a nearest loop surrounding the continue statement.
A keyword that indicates that it is a continue statement.
The end of a continue statement is represented by a semicolon.
Beginning of loop
A continue statement returns execution control to the beginning of a loop statement, but its position depends on the type of loop statement.
while ( Conditional-expression )
The conditional expression evaluates whether the loop can be executed.
The conditional expression is evaluated every loop. Therefore, the loop resumes from the evaluation of the conditional expression.
each ( Collection-expression )
The collection expression determines a target collection.
The target is evaluated only once at the beginning. Therefore, the loop resumes from the next statement of the collection expression.
fromto ( Start-index, End-index )
The start and end indexes determine the start and end values of the loop index.
The start and end indexes are evaluated only once at the beginning, but the current loop index is evaluated every loop. Therefore, the loop resumes from the evaluation of the current loop index.
keepon ( Number-expression )
The number expression determines the total number of loop.
The total number is evaluated only once at the beginning, but the number of loops is evaluated per loop. Therefore, the loop is restarted from the number of times evaluation.
open method void someMethod()
if(__index < 5)
When the someMethod() method is called, it rushes into a keepon loop.
At the beginning of the loop, the number of loops is stored in the reserved variable "__index".
If "__index" is 5 times or less, execution control returns with the continue statement.
From the sixth time onward, execution control returns in due to the "endkeepon".