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.

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

Similar Program

# Program Language
1 Java
2 Java
3 Java
4 Java
5 Java
6 Java
7 Java
8 Java
9 Java
10 Java
11 Java
12 Java
13 Java
14 Java
15 Java
16 Java
17 Java
18 Java
19 Java
20 Java
# Program Language