14.14. The for Statement

The for statement has two forms:

• The basic for statement.

• The enhanced for statement

ForStatement:    BasicForStatement    EnhancedForStatement

14.14.1. The basic for Statement

The basic for statement executes some initialization code, then executes an Expression, a Statement, and some update code repeatedly until the value of the Expression is false.

BasicForStatement:    for ( ForInitopt ; Expressionopt ; ForUpdateopt ) StatementForStatementNoShortIf:for ( ForInitopt ; Expressionopt ; ForUpdateopt ) StatementNoShortIfForInit:    StatementExpressionList    LocalVariableDeclarationForUpdate:    StatementExpressionListStatementExpressionList:    StatementExpression    StatementExpressionList , StatementExpression

Get The Java® Language Specification, Java SE 7 Edition, Fourth 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.