O'Reilly logo

Sun Certification Training Guide (310-025, 310-027): Java™ 2 Programmer and Developer Exams by Jamie Jaworski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Iteration Statements

Java provides three different types of iteration statements: for, while, and do. It also provides the continue statement to alter execution of for, while, and do. These statements, taken from C and C++, are used to repeat the execution of a statement or block of statements until a termination condition occurs.

The for Statement

The for statement repeatedly executes a statement or statement block and updates a variable (or group of variables) with each loop iteration. The syntax of the for statement is as follows:

for(initialization; boolean expression; iteration)
 statement block

A single statement can be used instead of the statement block. The execution of the for statement is executed as follows:

  1. The initialization statement(s) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required