Java Do While Loop
Java Do While Loop
The Java do-while loop is used to iterate a part of the program several times. If the number of iteration is not fixed and
you must have to execute the loop at least once, it is recommended to use do-while loop.
The Java do-while loop is executed at least once because condition is checked after loop body.
Syntax:
do{
//code to be executed
}while(condition);
Example:
Test it Now
Output:
1
2
3
4
5
6
7
8
9
10
Syntax:
do{
//code to be executed
}while(true);
Example:
Output: