6.10 Count-Controlled Loops Using for
Before the loop begins, if we know the number of times the loop body should execute, we can use a count-controlled loop. The for loop is designed for count-controlled loops, that is, when the number of iterations is determined before the loop begins.
6.10.1 Basic Structure of for Loops
The for loop has this syntax:
for ( initialization; loop condition; loop update ) { // loop body }
Notice that the initialization, loop condition, and loop update in the for loop header are separated by semicolons (not commas). Notice also that there is no semicolon after the closing parenthesis in the ...
Get Java Illuminated, 5th 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.