November 2012
Beginner
336 pages
8h 17m
English
In Chapter 4, “Using Java Arrays,” we used the while construct to populate an array with a section of repeating code. Without the means to loop through code the way we did, a task like populating an array is still possible, just far more cumbersome to implement. Loops can make any tedious, repetitive task easier to express in code. In this chapter, we’ll look at ways to use loops to make such tasks simpler and more economical.
Java supports four loop constructs. We’ll look at each one, compare them, and consider how best to apply each one. We’ll also look at how to break a loop when we arrive at odd conditions we can’t handle nicely in repeating code.
In this chapter, we’ll cover the following topics:
Read now
Unlock full access