int i = 1; while (i < 5) { System.out.print("i ="+ i); i++; }
An example of the do/while loop:
int i = 1; do { System.out.print("i ="+ i); i++; } while (i < 5)
The difference between the while loop and the do/while loop is that the test for the while loop is executed at the beginning of the loop in contrast to the test for the do/while loop which is executed at the bottom of the loop. Because of this difference, the statements in a do/while loop will be executed at least once.
Updated 30 January 2000.