Chapter 14. The Collections Framework

In this chapter you'll look at the Java collections framework, which consists of generic types that represent sets of collection classes. These generic types are defined in the java.util package, and they provide you with a variety of ways for structuring and managing collections of objects in your programs. In particular, the collection types enable you to deal with situations where you don't know in advance how many objects you'll need to store, or where you need a bit more flexibility in the way in which you access an object from a collection than the indexing mechanism provided by an array.

In this chapter you will learn:

  • What sets, sequences, and maps are, and how they work

  • What a Vector<T> collection object is and how to use Vector<T> objects in your programs

  • How to manage Vector<T> objects so that storing and retrieving elements is typesafe

  • What a Stack<T> collection is and how you use it

  • How you use the LinkedList<T> collections

  • How you store and retrieve objects in a hash table represented by a HashMap<K,V> object

  • How you can generate hashcodes for your own class objects

Get Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.