Specifications

Sun Services
Java™ Programming Language
Module 4, slide 24 of 31
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Looping Statements
The for loop:
for (
<init_expr>
;
<test_expr>
;
<alter_expr>
)
<statement_or_block>
Example:
for ( int i = 0; i < 10; i++ )
System.out.println(i + " squared is " + (i*i));
or (recommended):
for ( int i = 0; i < 10; i++ ) {
System.out.println(i + " squared is " + (i*i));
}