10 times
while Loop
Skip this page if you are clear how the while loop works.
But study it if you still have some doubts.
Here is the part of the program responsible for the loop:
// start count out at one
int count = 1;
// loop while count is <= 3
while ( count <= 3 )
{
System.out.println( "count is:" + count );
// add one to count
count = count + 1;
}
System.out.println( "Done with the loop" );
Here is how it works in tedious detail. Look especially at steps 7, 8, and 9.
count is assigned a 1.( count <= 3 ) is evaluated as true.count is written out: count is 1count is incremented by one, to 2.( count <= 3 ) is evaluated as true.count is written out. count is 2count is incremented by one, to 3.( count <= 3 ) is evaluated as true.count is written out. count is 3count is incremented by one, to 4.( count <= 3 ) is evaluated as FALSE.while execute?