September 18, 2018
Hot Topics:

Selecting the Best Java Collection Class for Your Application

  • July 15, 2009
  • By Mark Grand
  • Send Email »
  • More Articles »

Java provides classes that implement the Collection interface to contain a collection of objects. There are over 20 of these collection classes, each having different performance and organizing properties.

This article explains how to choose the most appropriate of these classes for a particular use.

Collection Classes

The Java interface java.util.Collection is implemented by classes and can contain or manage a collection of objects. Java provides over twenty concrete classes that implement the Collection interface. These classes differ in performance and how they organize objects. Some are for specialized purposes. If you are not familiar with the capabilities of these classes, deciding which one is most appropriate for a particular purpose can be a challenge.

Table 1 shows a list of the concrete classes that Java 1.6 provides.

Table 1: Concrete Java 1.6 Classes That Implement Collection
Package Class
java.beans.beancontext BeanContextServicesSupport
java.util ArrayDeque
java.util.concurrent ArrayBlockingQueue
javax.management AttributeList
javax.management.relation RoleList
javax.print.attribute.standard JobStateReasons

The classes in the java.util and java.util.concurrent packages are general purpose and have a wide range of uses. In contrast, the classes in the other packages are very specialized and used only for specific purposes with other classes in their individual packages.

  • The classes in the java.beans.beancontext package support bean contexts for JavaBeans development.
  • The classes in the javax.management and javax.management.relation packages are management beans that support remote administrative interfaces for programs.
  • The class in the javax.print.attribute.standard package is used by that package to help describe the current state of a print job.

That leaves 20 general-purpose classes to sort through. The most useful way to classify these is into two categories: how they organize objects, and how long they take to perform various operations. For most uses, how a Collection class organizes objects is more important than how quickly it can add, find, or remove them. Knowing that, let's focus on how these classes organize objects.

Page 1 of 4

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.


Thanks for your registration, follow us on our social networks to keep up-to-date