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

Visit Java Example Forums to request Java examples or ask Java questions!
OR
Try out our new Java Search Engine




Suggested Reading

Oracle Magazine
Contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more.
Cost: FREE

View/Subscribe
NASA Tech Briefs
Features exclusive reports of innovations developed by NASA and its industry partners/contractors that can be applied to develop new/improved products and solve engineering or manufacturing problems.
Cost: FREE

View/Subscribe
FierceBiotech IT
Is a free, easy to read weekly email service that brings must read biotech IT news to senior biotech, pharma, and IT executives.
Cost: FREE

View/Subscribe
Simply SQL
Simply SQL is a practical step-by-step guide to writing SQL.
Cost: FREE

View/Subscribe
Simply JavaScript
Packed with full-color examples, Simply JavaScript is all you need to start programming in JavaScript the right way.
Cost: FREE

View/Subscribe
PCMag.com's What's New Now
Lance Ulanoff, Editor in Chief of the PC Magazine Network, brings you this twice-weekly roundup of the latest top tech stories, the best new product reviews, plus special offers from Ziff Davis and its partners.
Cost: FREE

View/Subscribe

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


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




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