Name
Package java.util
Synopsis
The java.util
package
defines a number of useful classes, primarily collections classes
that are useful for working with groups of objects. This package
should not be considered merely a utility package that is separate
from the rest of the language; it is an integral and frequently used
part of the Java platform.
The most important classes in java.util
are the
collections classes. Prior
to Java 1.2, these were Vector
, a growable list of
objects, and Hashtable
, a mapping between
arbitrary key and value objects. Java 1.2 adds an entire collections
framework consisting of the Collection
,
Map
, Set
,
List
, SortedMap
, and
SortedSet
interfaces and the classes that
implement them. Other important classes and interfaces of the
collections framework are Comparator
,
Collections
, Arrays
,
Iterator
, and ListIterator
.
Java 1.4 extends the Collections framework with the addition of new
Map
and Set
implementations,
and a new RandomAccess
marker interface used by
List
implementations.
Java 5.0 adds a
Queue
collection interface and
implementations. It also adds
EnumSet
and
EnumMap
which efficiently implement the
Set
and Map
interfaces for use
with enumerated types. Most importantly, Java 5.0 modifies all
collection interfaces and classes to be generic types, which enable type-safe
collections such as List<String>
.
BitSet
is a related class that is not actually part of the Collections framework (and is not even a set). It provides a very compact representation of ...
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.