The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail Search
Feedback Form

Trail: Collections

Lesson: Introduction

What Is a Collection?

A collection (sometimes called a container) is simply an object that groups multiple elements into a single unit. Collections are used to store, retrieve and manipulate data, and to transmit data from one method to another. Collections typically represent data items that form a natural group, like a poker hand (a collection of cards), a mail folder (a collection of letters), or a telephone directory (a collection of name-to-phone-number mappings).

If you've used Java -- or just about any other programming language -- you're already familiar with collections. Collection implementations in earlier versions of Java included Vector (in the API reference documentation) , Hashtable (in the API reference documentation) , and array. While earlier versions of Java contained collection implementations, they 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 three things: The best known examples of collections frameworks are the C++ Standard Template Library (outside of the tutorial) (STL), and Smalltalk's collection classes.

What are the Benefits of a Collections Framework?

Are there any Drawbacks?

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 the following lessons.

Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail Search
Feedback Form

Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.