Java Reference
In-Depth Information
A
continue
statement with no label attempts to transfer control to the innermost enclosing
while
,
do
, or
for
statement of the immediately enclosing method, constructor, or initializer;
this statement, which is called the
continue target
, then immediately ends the current itera-
tion and begins a new one.
To be precise, such a
continue
statement always completes abruptly, the reason being a
con-
tinue
with no label.
If no
while
,
do
, or
for
statement of the immediately enclosing method, constructor, or initial-
izer contains the
continue
statement, a compile-time error occurs.
A
continue
statement with label
Identifier
attempts to transfer control to the enclosing
labeled statement (§
14.7
) that has the same
Identifier
as its label; that statement, which is
called the
continue target
, then immediately ends the current iteration and begins a new
one.
To be precise, a
continue
statement with label
Identifier
always completes abruptly, the reas-
on being a
continue
with label
Identifier
.
The continue target must be a
while
,
do
, or
for
statement, or a compile-time error occurs.
A
continue
statement must refer to a label within the immediately enclosing method, con-
structor, or initializer. There are no non-local jumps. If no labeled statement with
Identifier
as its label in the immediately enclosing method, constructor, or initializer contains the
con-
tinue
statement, a compile-time error occurs.
It can be seen, then, that a
continue
statement always completes abruptly.
statement (§
14.14
) for a discussion of the handling of abrupt termination because of
continue
.
The preceding descriptions say “attempts to transfer control” rather than just “trans-
whose
try
blocks or
catch
clauses contain the
continue
statement, then any
finally
clauses
of those
try
statements are executed, in order, innermost to outermost, before control
is transferred to the continue target. Abrupt completion of a
finally
clause can disrupt
the transfer of control initiated by a
continue
statement.