11.4. General Collections Methods

JDK 1.2 added to the collections significantly. It can be difficult to keep them straight, because their names (TreeMap, Map, HashMap, HashTable, HashSet) are so similar.

The Collection interface defines generic methods that you can use with any of the specific collection types. These are listed in Table 11.1.

Table 11.1. Generic Methods that Work with All Collections
Method Purpose
add(Object o) Inserts the specified element into the collection. Returns true.
addAll(Collection c) Adds all of the elements in the specified collection to this collection. Returns true.
clear() Removes all elements from this collection.
contains(Object o) Returns a boolean true if the specified element is contained in this collection. ...

Get Java™ for ColdFusion® Developers 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.