Java Do...While Loop
The do-while loop is almost like the while loop. This loop would run its statements at least once, regardless of whether the condition is not met for the first time or not.
Syntax
do {
// block of code
}
while
(condition);
Example:
public class
Main
{
public static void main(String[] args) {
int i
= 0;
do
{
System.out.println(i);
i++;
}
while
(i < 5);
}
}
Output:
0
1
2
3
4