Difference between revisions of "While Loops"

From CompSciWiki
Jump to: navigation, search
(Introduction)
m (Syntax)
Line 11: Line 11:
 
}
 
}
 
</pre>
 
</pre>
In this particular situation, the while loop will continue to iterate until the test condition evaluates to false.
+
In this particular situation, the while loop will continue to iterate as long as the test condition evaluates to true
  
 
==Test Condition==
 
==Test Condition==

Revision as of 16:50, 4 March 2007

Introduction

The while loop is a special form of loop that will continue to repeat as long as the test condition evaluates to false.

Syntax

In java, the while loop takes the form of

while(test condition) {
   ...
   statements
   ...
}

In this particular situation, the while loop will continue to iterate as long as the test condition evaluates to true

Test Condition

Uses