24 Dec 2017

Properties comparison among Collection classes.


Lets have a look to make easy comparison among the Collection classes based on some important properties.

Properties
--------------------
Class
Versions
Null insertion
Insertion Order
Synchronized
Duplicate Object
Data Structure
Cursor
Enumeration
Iterator
List Iterator
ArrayList
1.2v
Possible
Preserved
No
Allowed
Growable Array
No
Yes
Yes
LinkedList
1.2v
Possible
Preserved
No
Allowed
Double LinkedList
No
Yes
Yes
Vector
1.0v (legacy)
Possible
Preserved
Yes
Allowed
Growable Array
Yes
Yes
No
Stack
1.0v
Possible
Preserved
No
Allowed
Stack
Yes
Yes
No
HashSet
1.2v
Possible (once)
Not preserved
No
Not allowed
Hash set
No
Yes
No
LinkedHashSet
1.4v
Possible (once)
Preserved
No
Not allowed
HashSet & LinkedList
No
Yes
No
TreeSet
1.2v
Possible (once)
Not preserved
No
Not allowed
Balanced tree
No
Yes
No
HashMap
1.2v
Key possible (once)
Value (anytime)
Not preserved
No
Key not allowed (value allowed)
Hashtable
No
Yes
No
LinkedHashMap
1.4v
Key possible (once)
Value (anytime)
Preserved
No
Key not allowed (value allowed)
HashSet & LinkedList
No
Yes
No
TreeMap
1.2v
Key possible (once)
Value (anytime)
Not preserved
No
Key not allowed Value allowed
REDBLACK Tree
No
Yes
No
HashTable
1.0v (legacy)
Key and Value both not possible
Not preserved
Yes
Key and Value both allowed
Hashtable
Yes
Yes
No