Over 500 Magazines for FREE!

Yes! You can subscribe to ALL of them. They will be shipped to your home FREE of cost!
Kindly click here to apply!

Do While Loop

Do while loop executes group of Java statements as long as the boolean condition evaluates to true.

It is possible that the statement block associated with While loop never get executed because While loop tests the boolean condition before executing the block of statements associated with it.

In Java programming, sometime it's necessary to execute the block of statements at least once before evaluating the boolean condition. Do while loop is similar to the While loop, but it evaluates the boolean condition after executing the block of the statement.

Do While loop syntax

  1. Do{
  2.  
  3. <Block of statements>;
  4.  
  5. }while(<boolean condition>);

Block of statements is any valid Java code. Boolean condition is any valid Java expression that evaluates to boolean value. Braces are options if there is only one statement to be executed.

Do While Loop Examples

do while loop

example of do while loop?

Its given

Its already given.

Use this direct link if you can't locate it.
Do While Loop Example

do while loop in Java

  1.  
  2. int n = 12345;
  3. int t,r = 0;
  4. System.out.println("The original number : " + n);
  5. do{
  6. t = n % 10;
  7. r = r * 10 + t;
  8. n = n / 10;
  9. }while (n > 0);
  10. System.out.println("The reverse number : " + r);

another java statement

please post in ur site another do while, while, for statement programs tnx

Post new comment

To combat spam, please enter the code in the image.




Do you have a better example?
We're sure you have hundreds of Java program examples.

Spare some time and submit your java example here even if you think it's too small to contribute.

Could not find what you are looking for? Search Java Examples




Feel Tired? Read Jokes & Inspirational Stories, Play Games!