Appendix A: Collections API Reference
This appendix presents information to help you navigate through the classes in the Java Collections
Framework.
Class, Method, and Field Index
Table A−1 provides an index to all the classes, methods, and fields in the Java Collections Framework.
Classes specify which package they are in, while methods and fields specify what classes they belong to. For
detailed information about the classes, methods, and fields, see the chapters that describe them.
Table A−1: Summary of Collection Framework Classes, Methods, and Fields
CLASS/METHOD/FIELD NAME PACKAGE/CLASS FOR CLASS/METHOD/FIELD
A
AbstractCollection java.util
AbstractList java.util
AbstractMap java.util
AbstractSequentialList java.util
AbstractSet java.util
add() AbstractCollection, AbstractList, AbstractSequentialList,
ArrayList, Collection, HashSet, LinkedList, List, ListIterator,
Set, TreeSet, Vector
addAll() AbstractCollection, AbstractList, AbstractSequentialList,
ArrayList, Collection, LinkedList, List, Set, TreeSet, Vector
addElement() Vector
addFirst() LinkedList
addLast() LinkedList
and() BitSet
andNot() BitSet
ArrayList java.util
Arrays java.util
asList() Arrays
B
binarySearch() Arrays, Collections
BitSet java.util
C
capacity() Vector
capacityIncrement Vector
clear() AbstractCollection, AbstractList, AbstractMap, ArrayList,
BitSet, Collection, HashMap, HashSet, Hashtable, LinkedList,
250
List, Map, Set, TreeMap, TreeSet, Vector, WeakHashMap
clone() ArrayList, BitSet, HashMap, HashSet, Hashtable, LinkedList,
TreeMap, TreeSet, Vector
Collection java.util
Collections java.util
Comparable java.lang
Comparator java.util
comparator() SortedMap, SortedSet, TreeMap, TreeSet
compare() Comparator
compareTo() Comparable
contains() AbstractCollection, ArrayList, Collection, HashSet, Hashtable,
LinkedList, List, Set, TreeSet, Vector
containsAll() AbstractCollection, Collection, List, Set, Vector
containsKey() AbstractMap, HashMap, Hashtable, Map, TreeMap,
WeakHashMap
containsValue() AbstractMap, HashMap, Hashtable, Map, TreeMap
copy() Collections
copyInto() Vector
D
defaults Properties
Dictionary java.util
E
elementAt() Vector
elementCount Vector
elementData Vector
elements() Dictionary, Hashtable, Vector
empty() Stack
EMPTY_LIST Collections
EMPTY_MAP Collections
EMPTY_SET Collections
ensureCapacity() ArrayList, Vector
entrySet() AbstractMap, HashMap, Hashtable, Map, TreeMap,
WeakHashMap
Enumeration java.util
enumeration() Collections
equals() AbstractList, AbstractMap, AbstractSet, Arrays, BitSet,
Collection, Comparator, Hashtable, List, Map, Map.Entry, Set,
Vector
F
fill() Arrays, Collections
first() SortedSet, TreeSet
firstElement() Vector
Appendix A: Collections API Reference
251
firstKey() SortedMap, TreeMap
G
get() AbstractList, AbstractMap, AbstractSequentialList, ArrayList,
BitSet, Dictionary, HashMap, Hashtable, LinkedList, List,
Map, TreeMap, Vector, WeakHashMap
getFirst() LinkedList
getKey() Map.Entry
getLast() LinkedList
getProperty() Properties
getValue() Map.Entry
H
hashCode() AbstractList, AbstractMap, AbstractSet, BitSet, Collection,
Hashtable, List, Map, Map.Entry, Set, Vector
HashMap java.util
HashSet java.util
Hashtable java.util
hasMoreElements() Enumeration
hasNext() Iterator, ListIterator
hasPrevious() ListIterator
headMap() SortedMap, TreeMap
headSet() SortedSet, TreeSet
I
indexOf() AbstractList, ArrayList, LinkedList List, Vector
insertElementAt() Vector
isEmpty() AbstractCollection, AbstractMap, ArrayList, Collection,
Dictionary, HashMap, HashSet, Hashtable, List, Map, Set,
TreeSet, Vector, WeakHashMap
Iterator java.util
iterator() AbstractCollection, AbstractList, AbstractSequentialList,
Collection, HashSet, List, Set, TreeSet
K
keys() Dictionary, Hashtable
keySet() AbstractMap, HashMap, Hashtable, Map, TreeMap
L
last() SortedSet, TreeSet
lastElement() Vector
lastIndexOf() AbstractList, ArrayList, LinkedList, List, Vector
lastKey() SortedMap, TreeMap
length() BitSet
LinkedList java.util
List java.util
list() Properties
Appendix A: Collections API Reference
252
ListIterator java.util
listIterator() AbstractList, AbstractSequentialList, LinkedList, List
load() Properties
M
Map java.util
Map.Entry java.util
max() Collections
min() Collections
modCount AbstractList
N
nCopies() Collections
next() Iterator, ListIterator
nextElement() Enumeration
nextIndex() ListIterator
O
or() BitSet
P
peek() Stack
pop() Stack
previous() ListIterator
previousIndex() ListIterator
Properties java.util
propertyNames() Properties
push() Stack
put() AbstractMap, Dictionary, HashMap, Hashtable, Map, TreeMap,
WeakHashMap
putAll() AbstractMap, HashMap, Hashtable, Map, TreeMap
R
rehash() Hashtable
remove() AbstractCollection, AbstractList, AbstractMap,
AbstractSequentialList, ArrayList, Collection, Dictionary,
HashMap, HashSet, Hashtable, Iterator, LinkedList, List,
ListIterator, Map, Set, TreeMap, TreeSet, Vector,
WeakHashMap
removeAll() AbstractCollection, AbstractSet, Collection, List, Set, Vector
removeAllElements() Vector
removeElement() Vector
removeElementAt() Vector
removeFirst() LinkedList
removeLast() LinkedList
removeRange() AbstractList, ArrayList, Vector
retainAll() AbstractCollection, Collection, List, Set, Vector
Appendix A: Collections API Reference
253
reverse() Collections
reverseOrder() Collections
S
save() Properties
search() Stack
Set java.util
set() AbstractList, AbstractSequentialList, ArrayList, BitSet,
LinkedList, List, ListIterator, Vector
setElementAt() Vector
setProperty() Properties
setSize() Vector
setValue() Map.Entry
shuffle() Collections
singleton() Collections
singletonList() Collections
singletonMap() Collections
size() AbstractCollection, AbstractMap, ArrayList, BitSet, Collection,
Dictionary, HashMap, HashSet, Hashtable, LinkedList, List,
Map, Set, TreeMap, TreeSet, Vector, WeakHashMap
sort() Arrays, Collections
SortedMap java.util
SortedSet java.util
Stack java.util
store() Properties
subList() AbstractList, List, Vector
subMap() SortedMap, TreeMap
subSet() SortedSet, TreeSet
synchronizedCollection() Collections
synchronizedList() Collections
synchronizedMap() Collections
synchronizedSet() Collections
synchronizedSortedMap() Collections
synchronizedSortedSet() Collections
T
tailMap() SortedMap, TreeMap
tailSet() SortedSet, TreeSet
toArray() AbstractCollection, ArrayList, Collection, LinkedList, List, Set,
Vector
toString() AbstractCollection, AbstractMap, BitSet, Hashtable, Vector
TreeMap java.util
TreeSet java.util
Appendix A: Collections API Reference
254
trimToSize() ArrayList, Vector
U
unmodifiableCollection() Collections
unmodifiableList() Collections
unmodifiableMap() Collections
unmodifiableSet() Collections
unmodifiableSortedMap() Collections
unmodifiableSortedSet() Collections
V
values() AbstractMap, HashMap, Hashtable, Map, TreeMap
Vector java.util
W
WeakHashMap java.util
X
xor() BitSet
Class−Level API Index
In the tables that follow, you'll find the class summary tables from the earlier chapters recreated in a common
location for easy reference. They list the constructors, methods, and fields of each class in the Collections
Framework. For those constructors, methods, and fields that are protected, you'll find them listed in italic. In
all cases, the version of Java that the constructor, method, or field was introduced is mentioned as well as a
short description.
AbstractCollection Class
Table A−2: Summary of the AbstractCollection Class
VARIABLE/METHOD
NAME
VERSION DESCRIPTION
AbstractCollection() 1.2 Constructs an empty (abstract) collection.
add() 1.2 Adds an element to the collection.
addAll() 1.2 Adds a collection of elements to the collection.
clear() 1.2 Clears all elements from the collection.
contains() 1.2 Checks if the collection contains an element.
containsAll() 1.2 Checks if the collection contains a collection of elements.
isEmpty() 1.2 Checks if the collection is empty.
iterator() 1.2 Returns an object from the collection that allows all of the
collection's elements to be visited.
remove() 1.2 Clears a specific element from the collection.
removeAll() 1.2 Clears a collection of elements from the collection.
retainAll() 1.2 Removes all elements from collection not in another collection.
size() 1.2 Returns the number of elements in a collection.
Class−Level API Index
255
toArray() 1.2 Returns the elements of the collection as an array.
toString() 1.2 Converts the collection contents into a string.
AbstractList Class
Table A−3: Summary of the AbstractList Class
VARIABLE/METHOD NAME VERSION DESCRIPTION
AbstractList() 1.2 Constructs an empty (abstract) list.
modCount 1.2 Used by iterator to check for concurrent modifications
of the list.
add() 1.2 Adds an element to the list.
addAll() 1.2 Adds a collection of elements to the list.
clear() 1.2 Clears all elements from the list.
equals() 1.2 Checks for equality with another object.
get() 1.2 Returns an element at a specific position.
hashCode() 1.2 Returns the computed hash code for a list.
indexOf() 1.2 Searches for an element within the list.
iterator() 1.2 Returns an object from the list that allows all of the
list's elements to be visited.
lastIndexOf() 1.2 Searches from the end of the list for an element.
listIterator() 1.2 Returns an object from the collection that allows all of
the list's elements to be visited sequentially.
remove() 1.2 Clears a specific element from the list.
removeRange() 1.2 Clears a range of elements from the list.
set() 1.2 Changes an element at a specific position within the
list.
subList() 1.2 Returns a portion of the list.
AbstractMap Class
Table A−4: Summary of the AbstractMap Class
VARIABLE/METHOD NAME VERSION DESCRIPTION
AbstractMap() 1.2 Constructs an empty (abstract) map.
clear() 1.2 Removes all the elements from the map.
containsKey() 1.2 Checks to see if an object is a key within the map.
containsValue() 1.2 Checks to see if an object is a value within the map.
entrySet() 1.2 Returns the set of key−value pairs in the map.
equals() 1.2 Checks for equality with another object.
get() 1.2 Retrieves a value for a key in the map.
hashCode() 1.2 Computes a hash code for the map.
AbstractList Class
256
isEmpty() 1.2 Checks if the map has any elements.
keySet() 1.2 Retrieves a collection of the keys of the hash table.
put() 1.2 Places a key−value pair into the map.
putAll() 1.2 Places a collection of key−value pairs into the map.
remove() 1.2 Removes an element from the map.
size() 1.2 Returns the number of elements in the map.
toString() 1.2 Converts the map contents into a string.
values() 1.2 Retrieves a collection of the values of the map.
AbstractSequentialList Class
Table A−5: Summary of the AbstractSequentialList Class
VARIABLE/METHOD
NAME
VERSION DESCRIPTION
AbstractSequentialList() 1.2 Constructs an empty sequential list.
add() 1.2 Adds an element to the list.
addAll() 1.2 Adds a collection of elements to the list.
get() 1.2 Returns an element at a specific position.
iterator() 1.2 Returns an object from the list that allows all of the list's elements
to be visited.
listIterator() 1.2 Returns an object from the list that allows all of the list's elements
to be visited sequentially.
remove() 1.2 Clears a specific element from the list.
set() 1.2 Changes an element at a specific position within the list.
AbstractSet Class
Table A−6: Summary of the AbstractSet Class
VARIABLE/METHOD NAME VERSION DESCRIPTION
AbstractSet() 1.2 Constructs an empty set.
equals() 1.2 Checks for equality with another
object.
hashCode() 1.2 Computes a hash code for the set.
removeAll() 1.2 Clears a collection of elements
from the set.
ArrayList Class
Table A−7: Summary of the ArrayList Class
VARIABLE/METHOD NAME VERSION DESCRIPTION
ArrayList() 1.2 Constructs an empty list backed by an array.
AbstractSequentialList Class
257