Introduction

A collectionsometimes called a containeris simply an object that groups multiple elements into a single unit. Collections are used to store, to retrieve, and to manipulate data and to transmit data from one method to another. Collections typically represent data items that form a natural group, such as a poker hand (a collection of cards), a mail folder (a collection of letters), or a telephone directory (a mapping of names to phone numbers).

If you've used the Java programming languageor just about any other programming languageyou're already familiar with collections. Collection implementations in earlier versions of the Java platform included Vector, Hashtable, and array. Those earlier versions, however, did not contain a Collections Framework.

What Is a Collections Framework?

A Collections Framework is a unified architecture for representing and manipulating collections. All collections frameworks contain

The best-known examples of collections frameworks are the C++ Standard Template Library (STL) and Smalltalk's collection hierarchy.

Benefits

The Collections Framework provides the following benefits.

Drawbacks of the Collections Framework

Historically, collections frameworks have been quite complex, which gave them a reputation for having a steep learning curve. We believe that Java's new Collections Framework breaks with this tradition, as you will learn for yourself in this appendix.

Категории