Java Do While Loop Example 2

In the while loop condition will check first, then only it will execute the statement.

But in the do-while loop condition will check afterward the statement is executed.

Hence in the do-while loop at least one time, the statement is executed.

public class DoWhileLoop { public static void main(String[] args) { int i=1; do{ System.out.println("Hello"); i++; } while(i>5); } }