Java Articles

Submit Article
Home » Articles » Java » FundamentalRSS Feeds

do loop or do-while loop

Posted By: Khadeeja Malik     Category: Java     Views: 17219

This article explains about do loop or do-while loop in java with examples.

do-while statement provides a form of loop. do loop repeats the statement or statements while the expression is true. It stops when the expression becomes false.

Note that do-while loop is unique because it will always execute the code within the loop at least once, since the expression controlling the loop is tested at the bottom of the loop.

Syntax of do-while loop


Example of do-while loop

Example 1 : Program to print number from 1 to 10 using do-while loop

class DoWhileLoopDemo
  public static void main(String args[])
int i  = 1;

System.out.print("Numbers : ");

System.out.print(i + " ");
} while(i >= 10)


Numbers : 1 2 3 4 5 6 7 8 9 10


Didn't find what you were looking for? Find more on do loop or do-while loop Or get search suggestion and latest updates.

Khadeeja Malik
Khadeeja Malik author of do loop or do-while loop is from Karachi, Pakistan.
View All Articles

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!