Collections Framework
Collections Framework
Collections Framework
The Set
3
This extends Collection to handle sets, which must contain unique elements
The SortedSet
4
This extends Set to handle sorted sets
The Map
5
This maps unique keys to values.
The Map.Entry
6
This describes an element (a key/value pair) in a map. This is an inner class of Map.
The SortedMap
7
This extends Map so that the keys are maintained in ascending order.
The Enumeration
This is legacy interface and defines the methods by which you can enumerate (obtain one
8
at a time) the elements in a collection of objects. This legacy interface has been
superceded by Iterator.
The collection classes
Java provides a set of standard collection
classes that implement Collection interfaces.
Some of the classes provide full
implementations that can be used as-is and
others are abstract class, providing skeletal
implementations that are used as starting
points for creating concrete collections.
The standard collection classes are
summarized in the given table ( Click Table)
Standard Collection classes
•The ArrayList Class
•The LinkedList Class
•The HashSet Class
•The LinkedHashSet Class
•The TreeSet Class
How to use an Iterator ?
Often, you will want to cycle through the elements in a
collection. For example, you might want to display each
element.
The easiest way to do this is to employ an iterator, which
is an object that implements either the Iterator or the
ListIterator interface.
Iterator enables you to cycle through a collection,
obtaining or removing elements. ListIterator extends
Iterator to allow bidirectional traversal of a list, and the
modification of elements.
Here is a list of all the methods with examples provided
by Iterator and ListIterator interfaces.
The Methods Declared by Iterator: