Chapter 6. Arrays and tables

Arrays and tables

6.1 Simple arrays

6.2 Tables

6.3 The Graph class

6.4 Sorting and searching

6.5 Class-independent tables

Simple arrays

We are beginning to realize that there is a need to be able to store and manipulate multiple values in a program. If there are relatively few values, simple variables can possibly be used, but consider the following example.

Suppose we have several hundred scores between 0 and 19 which have to be analyzed for frequency of occurrence of each score. We could set up 20 counters, one for each score. As the scores are read in, the counter corresponding to the score could be incremented. It would be very unwieldy ...

Get Java Gently, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.