Java Reference
In-Depth Information
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, by-
passing the call to println( ) .
In while and do-while loops, a continue statement will cause control to go directly to
the conditional expression and then continue the looping process. In the case of the for , the
iteration expression of the loop is evaluated, then the conditional expression is executed,
and then the loop continues.
As with the break statement, continue may specify a label to describe which enclosing
loop to continue. Here is an example program that uses continue with a label:
Search WWH ::




Custom Search