A good answer might be:

Yes — there is the if statement (both with and without an else), the switch statement, and the conditional statement.

Of these, the if statement is by far the most useful.

The do Statement

The do statement is similar to the while statement with an important difference: the do statement performs a test after each execution of the loop body. Here is a counting loop that prints integers from 1 to 9:

int count = 0;                      // initialize count to 0

  System.out.println( count );      // loop body: includes code to
  count++  ;                        // change the count
while ( count < 10 );               // test if the loop body should be
                                    // executed again.

Notice how the do and the while bracket the statements that form the loop body. The condition that is tested follows the while.


Does the code fragment include the three things that all loops must do?