Java Reference
In-Depth Information
21.15. The Legacy Collection Types
The collection frameworkthe interfaces and classes described in this
chapter, and shown in Figure 21-1 on page 568 has not always been a
part of the package java.util , but that package has always contained
some other collections. Most are superseded by the new collection types.
Even so, they are not deprecated because they are in widespread use in
existing code and will continue to be used until programs shift over to the
new types. You are therefore likely to encounter these legacy collections
so you should learn about them, including their relationship to the newer
collection types. The legacy collections consist of the following types:
Enumeration Analogous to Iterator .
Vector Analogous to ArrayList , maintains an ordered list of ele-
ments that are stored in an underlying array.
Stack A subclass of Vector that adds methods to push and pop ele-
ments so that you can treat the vector by using the terms normal
to a stack.
Dictionary Analogous to the Map interface, although Dictionary is an
abstract class, not an interface. [4]
[4] Dictionary is not an interface because it predates the addition of interfaces to
the language, which gives you some idea of how old these legacy collections are.
Hashtable Analogous to HashMap .
Properties A subclass of Hashtable . Maintains a map of key/value
pairs where the keys and values are strings. If a key is not found in
a properties object a "default" properties object can be searched.
Of these types, only Properties is in active useit is used to contain system
properties, as described in " System Properties " on page 663 and by some
applications to store configuration data. We describe the other legacy
collections by contrasting them with their analogous types. We then de-
 
 
Search WWH ::




Custom Search