Java's New Collections
By Bruce Eckel
In my opinion, collection classes are among the most powerful tools for raw programming. You might have gathered that I'm somewhat disappointed in the collections provided in Java through version 1.1. As a result, it's a tremendous pleasure to see that collections have been given proper attention in Java 1.2, and thoroughly redesigned (by Joshua Bloch at Sun). I consider the new collections to be one of the two major features in Java 1.2 (the other is the Swing library, covered previously in this column) because they significantly increase your programming muscle and help bring Java in line with more mature programming systems.
Some aspects of the redesign make things tighter and more sensible. For example, many names are shorter, cleaner, and easier to understand, as well as easier to type. Some names have been changed to conform to accepted terminology: a particular favorite of mine is "iterator" instead of "enumeration." The redesign also fills out the functionality of the Collections library. You can now have the behavior of linked lists, queues, and dequeues (double-ended queues, pronounced "decks").
The designers of the new Collections library wanted to strike a balance: the full functionality that you expect from a mature Collections library, but easier to learn and use than, say, the Standard Template Library (STL) in C++. The result can seem a bit odd in places. Unlike some of the decisions made in the early Java libraries, these oddities were not accidents, but carefully considered decisions based on tradeoffs in complexity.