Java Collections Overview

Collections are objects whose sole purpose is to store other objects, like arrays. Unlike arrays, however, collections have convenience methods to, say, return a portion of the original collection. A drawback of collections is that they can't hold primitives. (They can, however, hold wrappers, like java.lang.Integer.)

All collection objects ultimately implement the java.util.Collection interface. However, few if any implement the interface directly. There are multiple sub-interfaces of Collection that specify additional methods. These sub-interfaces decide the functionality of a collection; individual classes usually differ only in implementation. (For example, both ArrayList and LinkedList fulfill the general contract of the List interface, but do so differently.)

Most implementations of the Collection interface are in java.util. Exceptions will be noted when introduced.

Although the Map interface does not extend Collection, it is usually included in discussions of collections and will be explained here.