Java Reference
In-Depth Information
We can't go into all these classes in detail, but to introduce you to how these can be applied we will
explore the three that you are likely to find most useful, Vector , LinkedList , and HashMap . Before
we get into the specifics of using the container classes we need to look at the interfaces they implement,
since these provide the means of applying them.
Collection Interfaces
The java.util package defines six collection interfaces that determine the methods that you use to
work with each type of collection class. There are three basic collection interfaces, the Set , List , and
Map interfaces, which relate to the fundamental organization of objects in a collection. These are
implemented amongst the classes as follows:
Interface
Implemented by
Set
HashSet , TreeSet
List
Vector , Stack , ArrayList , LinkedList
Map
Hashtable , TreeMap , HashMap , WeakHashMap
The relationships between the interfaces that are implemented by the collection classes are shown in
the following diagram.
Collection
Map
List
Set
SortedMap
SortedSet
Interfaces for Collection Classes
The Set and List interfaces both extend a common interface, Collection . Note that the Map
interface does not extend Collection . Don't confuse the Collection interface with the
Collections class (with an 's') that we will see later. The two other interfaces for collections are
SortedSet that extends the Set interface, and SortedMap that extends the Map interface. The
TreeSet class implements the SortedSet interface, and the SortedMap interface is implemented
by the TreeMap class.
Search WWH ::




Custom Search