Chapter 16

Using Loops and Arrays

IN THIS CHAPTER

check Using for loops to the max

check Storing many values in a single variable

check Working with groups of values

This chapter has ten illustrations. For these illustrations, the people at John Wiley & Sons, Inc. insist on the following numbering: Figure 16-1, Figure 16-2, Figure 16-3, Figure 16-4, Figure 16-5, Figure 16-6, Figure 16-7, Figure 16-8, Figure 16-9, and Figure 16-10. 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], figure[6], figure[7], figure[8], and figure[9]. In this chapter, you 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, ...

Get Beginning Programming with Java For Dummies, 5th 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.