Java-Do While Loop

Do While Loop

The do-while loop always executes its body at least once, because its conditional expression is at the bottom of the loop. Its general form is :

The do-while loop first executes the body of the loop and then evaluates the conditional expression. If this expression is true, the loop will repeat. Otherwise, the loop terminates.

Program

Program Source

class Javaapp {

    public static void main(String[] args) {
        
        int i=0;
        
        do{
            System.out.println("Value of i = "+i);
            i++;
        }while(i<5);
    }
}

Leave a Comment