Hello Guys,
Today we discuss about do-while loop.do-while loop is similar to while loop, however there is a difference between them: In while loop, condition is evaluated before the execution of loop’s body but in do-while loop condition is evaluated after the execution of loop’s body.

Syntax of do-while loop:

do
{
   statement(s);
}  while(condition);

How do-while loop works?

First, the statements inside loop execute and then the condition gets evaluated, if the condition returns true then the control gets transferred to the “do” else it jumps to the next statement after do-while.
Example ↬
class DoWhileLoopExample
{
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