Benefits
- Reduction of programming effort by useful algorithms and data structures
- High-quality and high-performance implementations of data structures
- Interoperability among different APIs
The Collection
interface is the root of the collection hierarchy. Direct implementation of this interface is not provided by the Java platform, but the direct implementation of the sub-interfaces are provided.
The main difference between set
and List
interfaces are: a set
can not contain duplicate elements but a List
can.
Both Queue
and Deque
are used to store multiple elements prior to processing.
Whereas a Map
contains values with respect to keys.
Different types of implementations
In Java platform there are three different types of implementations of Set
interface: HashSet
, TreeSet
, and LinkedHashSet
.
HashSet
is implemented based on the concept of Hash Table
, whereas TreeSet
is implemented based on the concept of Red-Black Tree
. LinkedHashSet
is implemented based on the concept of Hash Table with Linked List
.
There are two types of implentations of List
interface in Java. Those are ArrayList
and LinkedList
.
According to the basic concept of data structure, Queue
stores the elements in order of their arrival (according to FIFO).
Deque
is double-ended-queue, which is nothing but a linear collection of elements. Now, try to write a simple program using Deque
.
The Java platform contains three Map implementations: HashMap
, TreeMap
, and LinkedHashMap
.
The Java Collection framework is an architecture to store and manipulate a group of similar objects. It provides required operations like searching, sorting, insertion, deletion, updation etc.
Java Collection framework provides many interfaces such as Set, List, Queue, Deque, etc.
It has many classe implementations such as ArrayList, Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet, TreeSet, etc.
The relationship among classes and interfaces are shown in the following figure.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.