... and increment modifies the control variable’s value, so that the loop-continuation condition eventually becomes false. The two semicolons in the for header are required. If the loop-continuation condition is initially false, the program does not execute the body. Instead, execution proceeds with the statement following the for.

Representing a for Statement with an Equivalent while Statement

The for statement often can be represented with an equivalent while statement as follows:

initialization;
while (loopContinuationCondition) {
   statements
   increment;
}

In Section 5.8, we show a case in which a for statement cannot be represented with an equivalent while statement. Typically, for statements are used for counter-controlled iteration and while ...

Get Java How to Program, Early Objects, 11th 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.