Collections
Collections are data structures that
are fundamental to all types of programming. Whenever we need to refer to
a group of objects, we have some kind of collection. At the core language
level, Java supports collections in the form of arrays. But arrays are
static and because they have a fixed length, they are awkward for groups
of things that grow and shrink over the lifetime of an application. Arrays
also do not represent abstract relationships between objects well. In the
early days, the Java platform had only two basic classes to address these
needs: the java.util.Vector class,
which represents a dynamic list of objects, and the java.util.Hashtable class, which holds a map of
key/value pairs. Today, Java has a more comprehensive approach to
collections called the Collections Framework. The older classes still
exist, but they have been retrofitted into the framework (with some
eccentricities) and are generally no longer used.
Though conceptually simple, collections are one of the most powerful parts of any programming language. Collections implement data structures that lie at the heart of managing complex problems. A great deal of basic computer science is devoted to describing the most efficient ways to implement certain types of algorithms over collections. Having these tools at your disposal and understanding how to use them can make your code both much smaller and faster. It can also save you from reinventing the wheel.
Prior to Java 5, the Collections Framework ...