The For Statement
Provides a convenient way to repeat another statement for a certain number of times.
General Form
for (initializationStatementexpressionnextIterationStatement) statement
The for statement behaves exactly like the following:
initializationStatement while (expression) { statement nextIterationStatement }
Note: As with the while statement, the nested statement will not be performed at all if the expression is false the first time it's tested.
The initialization statement and the next-iteration statement must both be simple statements. The initialization statement can be a variable declaration statement. This makes it easy to create a local index variable that's used only in the context of the for statement. (When the entire for statement exits, that variable is discarded.)