do … while loop

Save & Share

 

 

 

 

 

 

 

 

 

 

 

In the do ... while loop the test is done after each iteration. Consequently, the code is always executed at least once.

Example:

 
 
   1:  // doSomethingUseful() is called at least once
   2:  do {
   3:      doSomethingUseful();
   4:  } while (i < 10);

	

The text content of this page derived from wikipedia.org Java syntax page and available under the Creative Commons Attribution-ShareAlike License.  The original work has been modified.

Posted in Iteration statements • • Top Of Page