Sunday 13 March 2016

The Java Language: do/while loops

The do and while iterative statements have the familiar functionality; their conditional test is also a Boolean expression:

 while ( condition )  
 statement;  
 do  
 statement;  
 while ( condition );  
For example:
 while( queue.isEmpty() )  
 wait();  
Unlike while or for loops (which we’ll see next) that test their conditions first, a dowhile loop always executes its statement body at least once.

0 comments:

Post a Comment