4. 6. 1. for语句 |
|
The for statement is like the while statement, i.e. you use it to create loop.
The for statement has following syntax: |
for ( init ; booleanExpression ; update ) {
statement (s)
}
|
|
- init is an initialization that will be performed before the first iteration.
- booleanExpression is a boolean expression which will cause the execution of statement(s) if it evaluates to true.
- update is a statement that will be executed after the execution of the statement block.
- init, expression, and update are optional.
|
The for statement will stop only if one of the following conditions is met: |
- booleanExpression evaluates to false
- A break or continue statement is executed
- A runtime error occurs.
|