Do-While Loop In Java

The Do-While Loop is used to iterate the part of the program several times and if the number of iteration is not fixed and you have to execute the program atleast once then you can use Do-While loop.

class DoWhile
{
public static void main(String args[])
{
int i=1;
do
{
System.out.println(i);
i++;
}
while(i<=10);
}
}
Output:
1
2
3
4
5
6
7
8
9
10

Leave a Reply