September 2011
Beginner
650 pages
15h 47m
English
It is possible to force an early iteration of a loop, bypassing the loop’s normal control structure. This is accomplished using continue. The continue statement forces the next iteration of the loop to take place, skipping any code between itself and the conditional expression that controls the loop. Thus, continue is essentially the complement of break. For example, the following program uses continue to help print the even numbers between 0 and 100:

Only even numbers are printed, because an odd one will cause the loop to iterate early, bypassing the call to println( ).
In while and do-while loops, a continue statement will cause ...
Read now
Unlock full access