Java Reference
In-Depth Information
Enhanced for loops allow for automatic iteration over iterable objects like arrays. On the other
hand, do while loops offer an alternative syntax to while loops and can allow the first iteration to
occur before testing the condition.
Finally, you looked at some keywords and how they can also be used to control the flow of a
program. Any method will be interrupted and exited when the return keyword is encountered.
In this way, you can influence how much of a method is evaluated and executed. The break key-
word, with and without a label, can also control how loops and other structures are evaluated
by exiting a loop immediately. The continue keyword works similarly, but by jumping to the
next iteration of a loop.
Because these structures are so common, they will be used throughout the remainder of this topic.
This will give you a chance to continue practicing, but it also means it's important that you feel
comfortable with the ideas in this chapter before continuing. If you can follow the execution of the
programs from the Try It Out and How It Works exercises, you're probably ready to move on to the
later chapters.
Search WWH ::




Custom Search