The core collection interfaces encapsulate different types of collections, which are shown in the figure below. These interfaces allow collections to be manipulated independently of the details of their representation. Core collection interfaces are the foundation of the Java Collections Framework. As you can see in the following figure, the core collection interfaces form a hierarchy.
The following list describes the core collection interfaces:
Collection
— the root of the collection hierarchy. A collection represents a group of
objects known as
its elements. The Collection interface is the least common denominator that all collections implement
and is used to pass collections around and to manipulate them when maximum generality is desired. Some
types of collections allow duplicate elements, and others do not. Some are ordered and others are
unordered. The Java platform doesn't provide any direct implementations of this interface but provides
implementations of more specific subinterfaces, such as Set and List. Also see The Collection Interface
section.
Set
— a collection that cannot contain duplicate elements. This interface models the
mathematical set
abstraction and is used to represent sets, such as the cards comprising a poker hand, the courses making
up a student's schedule, or the processes running on a machine. See also The Set Interface section.
List
— an ordered collection (sometimes called a sequence). Lists can contain duplicate
elements. The
user of a List generally has precise control over where in the list each element is inserted and can
access elements by their integer index (position). If you've used Vector, you're familiar with the
general flavor of List. Also see The List Interface section.
Queue
— a collection used to hold multiple elements prior to processing. Besides basic
Collection
operations, a Queue provides additional insertion, extraction, and inspection operations.
Deque
— a collection used to hold multiple elements prior to processing. Besides basic
Collection
operations, a Deque provides additional insertion, extraction, and inspection operations.
Map
— an object that maps keys to values. A Map cannot contain duplicate keys; each key can
map to at
most one value. If you've used Hashtable, you're already familiar with the basics of Map. Also see The
Map Interface section.