Java Reference
In-Depth Information
6.
Here is a sample run.
The for Loop
at just how powerful and flexible the
for
loop is. Let's begin by reviewing the basics, start-
ing with the most traditional forms of the
for
.
The general form of the
for
loop for repeating a single statement is
for(
initialization
;
condition
;
iteration
)
statement
;
For repeating a block, the general form is
Ask the Expert
Q
:
Under what conditions should I use an
if-else-if
ladder rather than a
switch
when coding a multiway branch?