A Java do loop is similar to the Java while loop, except that the while test happens at the bottom of the loop. This means that the loop always executes at least once.

The syntax of a do loop in Java is:

 do {
} while (expression);

Here is a Java do loop that prints the number 1 -- even though the test fails.

 int loopvar = 1;                 // Declare and initialize the loop counter
do {
   System.out.println(loopvar);  // Print the variable
   loopvar = loopvar + 1;        // Increment the loop counter
} while (loopvar >= 10);         // Test and loop