Do While Loop Java

Sharing is healthy !!

In this post you will learn do while loop java.

Do While LOOP

Do while loop java statement assess its expression at the bottom of the loop rather of the top. Here’s syntax and example,

Syntax:
do
{
statement(s);
}while(expression);

Also Read – Java If Else

Flow Diagram

Do While Loop Java

Example:
public class Do_While {

public static void main(String[] args) {

int x = 0;
do
{
System.out.println("x value is: " + x);
x++;
}while(x < 6);

}
}

Output:

x value is: 0
x value is: 1
x value is: 2
x value is: 3
x value is: 4
x value is: 5

Sharing is healthy !!

Leave a Reply

Your email address will not be published.