The Collections Framework was introduced in Java 2 as a set of interfaces and classes that are superior to many of the interfaces and classes found in the earlier java.util
package such as Vector
, Stack
, and HashTable
. These interfaces and classes should always be used instead of the older ones whenever possible. Many of the Collection Framework interfaces and classes are summarized in the following table:
Interface |
Class |
---|---|
Set |
|
List |
|
Map |
|
The Collection Framework is covered in more detail at http://java.sun.com/developer/onlineTraining/collections/Collection.html. Here, we will address the ArrayList
class as it is a certification topic. It is recommended that the ArrayList
class be used when a List
is needed. As we will see, iterators are used with the ArrayList
to support traversal of the list. We will start our discussion with coverage of this topic.