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