Content deleted Content added
m →Type import declaration: added package - etc. Check this please. |
m →Iteration statements: commas |
||
Line 519:
===Iteration statements===
Iteration statements are statements that are repeatedly executed when a given condition is evaluated as true. Since [[J2SE 5.0]], Java has four forms of such statements.
====<code>while</code> loop====
In the <code>while</code> loop, the test is done before each iteration.
<source lang=Java5>
Line 531:
====<code>do ... while</code> loop====
In the <code>do ... while</code> loop, the test is done after each iteration. Consequently, the code is always executed at least once.
<source lang=Java5>
Line 541:
====<code>for</code> loop====
<code>for</code> loops in Java include an initializer, a condition and a counter expression. It is possible to include several expressions of the same kind using comma as delimiter (except in the condition). However, unlike C, the comma is just a delimiter and not an operator.
<source lang=Java5>
Line 554:
</source>
Like C, all three expressions are optional
<source lang=Java5>
for (;;) {
Line 563:
====Enhanced <code>for</code> loop====
[[enhanced for loop|Enhanced <code>for</code> loop]]s have been available since [[J2SE 5.0]]. This type of loop uses built-in iterators over arrays and collections to return each item in the given collection. Every element
<source lang=Java5>
|