| |
Java
provides a wide range of collections, Package : java.util. In java Collection is an interface.
Collections are classified into three types. "Why need
collections?
We know that class java.lang.Array,
an array holds similar data types and its size is defined
while initializing, some times when there is a dynamic
environment,the size of
the array may have to be changed from time to time, which is not possible always. to address these
issues SUN has come with
collections, In java 1.5 it has gone more advanced, here we are
trying to give a clear understanding of all the collections, will
work for java 1.4 versions.
The following table is the
classified explanation of all the collections
|
Set |
List |
Map |
|
Only Unique values |
Can store duplicates |
Store a Key and a pair value |
|
|
-
Arraylist(
Can store duplicates
and it's not synchronized)
-
Vector
(Can store duplicates and it's
synchronized)
-
LinkedList(Can store duplicates order of
entry
is guaranteed. Can add
elements first and last. it can
be acted like Queue, Stack or Deque)
|
(Key pair value & can store one null
key based value and not synchronized)
(Key pair value & can notstore one null
key based value and synchronized )
(Key pair value in sorted key based
order of entry).
(Key pair value in sorted key based
order.)
|
|