Java Reference
In-Depth Information
10.5. for
The for statement comes in two forms: a basic and an enhanced form.
The basic form is the more general and powerful of the two.
10.5.1. Basic for Statement
You use the basic for statement to loop over a range of values from be-
ginning to end. It looks like this:
for ( initialization-expression ;
loop-expression ;
update-expression )
statement
The initialization-expression allows you to declare and/or initialize loop
variables, and is executed only once. Then the loop-expression of boolean
or Boolean typeis evaluated and if it is true the statement in the body of
the loop is executed. After executing the loop body, the update-expression
is evaluated, usually to update the values of the loop variables, and then
the loop-expression is reevaluated. This cycle repeats until the loop-ex-
pression is found to be false . This is roughly equivalent to
{
initialization-expression ;
while ( loop-expression ) {
statement
update-expression ;
}
}
 
Search WWH ::




Custom Search