The for loop as you have learned it provides a means of iterating through a collection and operating on each element. You will need more general-purpose looping. Perhaps you need to execute a body of code infinitely, loop until some condition is met, or send a message ten times. Java meets these needs with three looping constructs: while, do, and for. |