for (statement ; condition ; iterationExpression) {
body;
}
'statement' is executed before the loop itself is started.
'condition' must be a boolean expression.
'body' will be executed repeatedly until the condition ceases to be true.
iterationExpression is executed immediately after the body of the loop.
commas separates multiple statements in the initialization and iteration part of the statement.
public class MainClass {
public static void main(String[] argv) {
for (int i = 0; i < 5; i++) {
System.out.println(i);
}
}
}
|