Java Reference
In-Depth Information
2.
Second, another
for
iteration step is performed.
♦ If the
for
statement does not have label
L
, the
for
statement completes abruptly
because of a
continue
with label
L
.
• If execution of the
Statement
completes abruptly for any other reason, the
for
state-
ment completes abruptly for the same reason.
Note that the case of abrupt completion because of a
break
with a label is handled by
14.14.2. The enhanced
for
statement
The enhanced
for
statement has the form:
EnhancedForStatement:
for (
FormalParameter
:
Expression
)
Statement
FormalParameter:
VariableModifiers
opt
Type VariableDeclaratorId
VariableDeclaratorId:
Identifier
VariableDeclaratorId
[]
occurs.
The scope and shadowing of a local variable declared in the
FormalParameter
part of an
The meaning of the enhanced
for
statement is given by translation into a basic
for
statement,
as follows:
• If the type of
Expression
is a subtype of
Iterable
, then the translation is as follows.
If the type of
Expression
is a subtype of
Iterable
<
X
> for some type argument
X
, then
let
I
be the type
java.util.Iterator
<
X
>; otherwise, let
I
be the raw type
java.util.Iterator
.
The enhanced
for
statement is equivalent to a basic
for
statement of the form:
for (
I
#i =
Expression
.iterator(); #i.hasNext(); ) {
VariableModifiers
opt
TargetType Identifier
=