The Collections Framework

   

A significant design change introduced in the Java 1.2 API and updated somewhat in the Java 1.3 release relates to how collections of objects are created and manipulated. Earlier versions of the language provided the Vector, Hashtable, and Stack classes for limited collection functionality, but Java 1.2 increased this support dramatically. Collections are now supported by a number of interfaces and classes in the java.util package known as the Java collections framework.

A collection is nothing more than a type of data structure, which refers to a grouping of multiple data elements. You already saw the simplest Java collection, the array, back in Chapter 3, "Data Types and Other Tokens." Collections can vary in complexity, but ultimately their goal is always to hold and manipulate primitives or objects.

Some collections, such as arrays, keep data in one long list. Others, such as trees, keep the data sorted in non-linear storage compartments. Each type of collection has its advantages and disadvantages. For instance, trees are extremely efficient at finding and inserting sorted data; hash tables are even more efficient at finding data, but at the cost of more memory usage.

Before collections, converting between one data structure and another required a lot of work. However, the collection framework provides a uniform mechanism for doing this. In addition, the framework is designed to allow characteristics, such as the ordering of an object, to be used in many types of structures.

   


Special Edition Using Java 2 Standard Edition
Special Edition Using Java 2, Standard Edition (Special Edition Using...)
ISBN: 0789724685
EAN: 2147483647
Year: 1999
Pages: 353

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net