The do-while is similar to the while loop . In do-while loop, the condition is evaluated after the execution of statements with in the do block at least once.

Syntax:

1
2
3
4
do
{
   //statement(s);
} while(condition);

Sample Program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
package ClassThreeControlFlowStatements;
 
public class DoWhileLoop {
 
      public static void main(String[] args) {
            int i=10;
            do{
                 System.out.println(i);
                 i;
            }
             while(i>1);
            }
 
}

Must Read: Java Tutorial