[ First Section | Previous Chapter | Next Chapter | Main Index ]

Chapter 7

Arrays and ArrayLists

Computers get a lot of their power from working with data structures. A data structure is an organized collection of related data. An object is a data structure, but this type of data structure -- consisting of a fairly small number of named instance variables -- is just the beginning. In many cases, programmers build complicated data structures by hand, by linking objects together. We'll look at these custom-built data structures in Chapter 9. But there is one type of data structure that is so important and so basic that it is built into every programming language: the array.

You have already encountered arrays in Section 3.8 and Subsection 5.1.4. We continue the study of arrays in this chapter, including some new details of their use and some additional array-processing techniques. In particular, we will look at the important topic of algorithms for searching and sorting an array.

An array has a fixed size that can't be changed after the array is created. But in many cases, it is useful to have a data structure that can grow and shrink as necessary. In this chapter, we will look at a standard class, ArrayList, that represents such a data structure.

Contents of Chapter 7:

[ First Section | Previous Chapter | Next Chapter | Main Index ]