Collections

The Collection Interface has been around in previous versions, e.g. 1.4.2 java.util

As of JDK 5.0, 1.5.0 java.util however, the collection classes are Generic Classes with type parameters.

From Core Java, Volume I Chapter 13:



Collections Framework

Discuss Collections Framework Overview: Interfaces ( Collection , Set, List, Queue, etc.), AbstractClasses ( AbstractCollection, AbstractList, AbstractSequentialList, AbstractSet, AbstractQueue, AbstractMap), Concrete Classes

Concrete Collections

Table 2–1: (from Core Java, Volume II, Chapter 2)

Concrete Collections in the Java Library
Collection TypeDescription
ArrayList An indexed sequence that grows and shrinks dynamically
LinkedList An ordered sequence that allows efficient insertions and removal at any location
HashSet An unordered collection that rejects duplicates
TreeSet A sorted set
EnumSet A set of enumerated type values
LinkedHashSet A set that remembers the order in which elements were inserted
PriorityQueue A collection that allows efficient removal of the smallest element
HashMap A data structure that stores key/value associations
TreeMap A map in which the keys are sorted
EnumMap A map in which the keys belong to an enumerated type
LinkedHashMap LinkedHashMap A map that remembers the order in which entries were added
WeakHashMap A map with values that can be reclaimed by the garbage collector if they are not used elsewhere
IdentityHashMap A map with keys that are compared by ==, not equals

Example of creation and use of ArrayList here

Again, as of JDK 5.0 however, the collection classes are Generic Classes with type parameters.
Example of using the parameter for a LinkedList of String

If you use older versions of of Java, you drop the type parameter and replace the generic types with the Object type.

Chapter 13 in Volume 1 is on Generic Programming, Chapter 2 (pdf) in Volume II is on Collections.

Collections Tutorial with

Generic materials Note the enhanced "for each" iterator for Collections.
The "for each" loop works with any object that implements the Iterable Interface. The Collection interface extends the Iterable Interface.

See also Java in a Nutshells link on collections

From Generics Tutorial:

Type Parameter Naming Conventions

By convention, type parameter names are single, uppercase letters. This stands in sharp contrast to the variable naming conventions that you already know about, and with good reason: Without this convention, it would be difficult to tell the difference between a type variable and an ordinary class or interface name.

The most commonly used type parameter names are:

You'll see these names used throughout the Java SE API and the tutorials.

Oh, and since it is in this online book too - about the question in class about Java and memory leaks.