JAVA programs

Java Program Using do while loop

In this program we demonstrate use of the do-while loop. Do- while loop is a flow control statement that allows statement block to be executed repeatedly based on a given condition (Boolean condition).

This loop will execute the Statement block once, before checking if the condition is true, and then it will repeat the loop as long as the condition is true. That means code block will execute at least once.


public class Dowhiledemo


    public static void main(String[] args)


        int i=1;



            System.out.println("value of i is:"+i);






When Run The Program Following Output:

value of i is:1

value of i is:2

value of i is:3

value of i is:4

value of i is:5


Syntax of do-while loop


do {
// Statement block to be executed
while (condition);


In do while loop firstly code is executed and then the given condition is checked. That means code block will execute at least once.

Releted Programs

© 2017 codewmAll rights reserved.