Now let's take a look at the key classes and interfaces provided by the Java collections framework:
Collection Interface
This is the root of the collection hierarchy. A collection represents a
group of objects known as its elements. The Java platform doesn’t
provide any direct implementations of this interface.
Set Interface
A collection that contains no duplicate elements. s implied by its
name, this interface models the mathematical set abstraction. Most
common implementations of set are HashSet,TreeSet and LinkedHashSet.
List Interface
list is an ordered collection of objects which can contain duplicate
elements. List is like a growable array. Most commonly used
implementations of List are ArrayList and LinkedList.
Map Interface
map, as the name suggests, is an interface that provides implementation
to map keys to values. A map cannot contain a duplicate key. Each key
can be mapped to only one value. Three general-purpose implementations
of map are HashMap, TreeMap and LinkedHashMap.
* map interface does not extend the collection interface. Map interface does not comes under collection hierarchy. But we can get Collections from a Map (like keySet() ) a set of keys, thus map is considered to described with collection framework.
Queue Interface
Queue is a collection used to hold multiple elements prior to
processing. Besides basic Collection operations, a Queue provides
additional insertion, extraction, and inspection operations.
Queues typically, but do not necessarily, order elements in a FIFO (first-in, first-out) manner. Among the exceptions are priority queues, which order elements according to a supplied comparator or the elements’ natural ordering. Whatever the ordering used, the head of the queue is the element that would be removed by a call to remove or poll. In a FIFO queue, all new elements are inserted at the tail of the queue.
COMMENTS