## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

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 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, ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required