Java Dowhile Loop Control Statement with Program Example

In this java programming tutorial post, we will study and understand the working of Java Dowhile Loop Control Statement which is a looping control statement. We will also see a program example to understand the practical working of the Dowhile loop in java.

Dowhile 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.

Java Dowhile Loop flow diagram

Syntax:
do{  
//code to be executed  
}while(condition);
Program Example –
public class DoWhileExample {  
public static void main(String[] args) {  
    int i=10;  
    do{  
        System.out.println(i); // the loop will execute once even when i=10 and condition is i<10  
    i++;  
    }while(i<10);  
}  
}
Output
10
Watch it on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *