Non-trivial computing problems often require storing lists of items. Often these items can be referred to by their position in the list. Sometimes this ordering is natural as in a list of the first ten people to arrive at a sale. The first person would be item one in the list, the second person to arrive would be item two, and so on. Other times the ordering doesn't really mean anything, but it's still convenient to be able to assign each item a unique number and enumerate all the items in a list by counting out the numbers.

There are many ways to store lists of items including linked lists, sets, hash tables, binary trees and arrays. Which one you choose depends on the requirements of your application and the nature of your data. Java provides classes for many of these ways to store data. In this chapter youšll explore the simplest and most common, the array.

In this chapter you learn about

- Arrays, their declaration, initialization and use
- Multidimensional arrays
- Searching
- Sorting

- Example 9.1: Test The Randomness of a Random Number Generator
- Example 9.2: Fill a Two-Dimensional Array with the sum of the row and column indexes
- Example 9.3: The Identity Matrix
- Example 9.4: Fill a three-dimensional array with the sum of the row and column indexes
- Example 9.5: An Incorrect Swapping Algorithm
- Example 9.6: A Correct Swapping Algorithm
- Example 9.7: Bubble Sort

Examples from Other Chapters

[ Cafe Au Lait | Books | Trade Shows | Links | FAQ | Tutorial | User Groups ]

Copyright 1996 Elliotte Rusty Harold

elharo@sunsite.unc.edu

Last Modified July 23, 1996