A Closer Look at the for Statement’s Header

Figure C.14 takes a closer look at the for statement in Fig. C.13. The for’s first line (including the keyword for and everything in parentheses after for)—line 10 in Fig. C.13—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. If the loop-continuation condition is initially false, the program does not execute the for statement’s body—execution proceeds with the statement following the for.

Fig. C.14 | for statement header components.

Get Android™ How to Program, Second 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.