A Closer Look at the for Statement’s Header

Figure 5.3 takes a closer look at the for statement in Fig. 5.2. The first line—including the keyword for and everything in parentheses after for (line 10 in Fig. 5.2)—is sometimes called the for statement header. The for header “does it all”—it specifies each item needed for counter-controlled repetition with a control variable. If there’s more than one statement in the body of the for, braces are required to define the body of the loop.

Image

Fig. 5.3 | for statement header components.

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.