Chapter 16
Using Loops and Arrays
In This Chapter
Using for loops to the max
Storing many values in a single variable
Working with groups of values
This chapter has seven illustrations. For these illustrations, the people at Wiley Publishing insist on following numbering: Figure 16-1, Figure 16-2, Figure 16-3, Figure 16-4, Figure 16-5, Figure 16-6, and Figure 16-7. But I like a different kind of numbering. I’d like to number the illustrations figure[0]
, figure[1]
, figure[2]
, figure[3]
, figure[4]
, figure[5]
, and figure[6]
. In this chapter, you’ll find out why.
Some Loops in Action
The Java Motel, with its ten comfortable rooms, sits in a quiet place off the main highway. Aside from a small, separate office, the motel is just one long row of ground floor rooms. Each room is easily accessible from the spacious front parking lot.
Oddly enough, the motel’s rooms are numbered 0 through 9. I could say that the numbering is a fluke — something to do with the builder’s original design plan. But the truth is, starting with 0 makes the examples in this chapter easier to write.
You, as the Java Motel’s manager, store occupancy data in a file on your computer’s hard drive. The file has one entry ...
Get Beginning Programming with Java® For Dummies®, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.