Java Reference
In-Depth Information
10.8. continue
A continue statement can be used only within a loop ( for , while , or do )
and transfers control to the end of the loop's body to continue on with the
loop. In the case of while and do loops, this causes the loop expression
to be the next thing evaluated. In a basic for loop continue causes the
update-expression to be evaluated next and then the loop expression. In
the enhanced for loop execution goes to the next element in the set of
values if there is one.
Like the break statement, the continue statement has an unlabeled form:
continue;
and a labeled form:
continue label ;
In the unlabeled form, continue transfers control to the end of the inner-
most loop's body. The labeled form transfers control to the end of the
loop with that label. The label must belong to a loop statement.
A continue is often used to skip over an element of a loop range that can
be ignored or treated with trivial code. For example, a token stream that
included a simple "skip" token might be handled this way:
while (!stream.eof()) {
token = stream.next();
if (token.equals("skip"))
continue;
// ... process token ...
}
 
Search WWH ::




Custom Search