Collection - List, Set and Map all properties in tabular form in java



Hi! In this Collection framework tutorial we will find differences and similarities in most important properties of most widely used Collection framework classes like whether they allows Duplicate elements, maintain insertion order, is Sorted by natural order, allow null elements and Iterator is fail-safe or fail-fast.



Duplicate elements
insertion order
Sorted by natural order
null elements
Iterator
Yes
Yes


Yes
Iterator & listIterator
are
Yes
Yes


Yes
Iterator & listIterator
are
Fail-fast
Yes
Yes

Yes
Yes
Iterator & listIterator
are
Fail-fast
Yes
Yes

Yes
Yes
Iterator & listIterator
are







Duplicate elements
insertion order
Sorted by natural order
synchronized
null elements
Iterator




Yes
Fail-fast



Yes
Yes
Fail-safe

Yes


Yes
Fail-fast


Yes

No
Fail-fast


Yes
Yes
No
Fail-safe







Duplicate Keys
insertion order of keys
Sorted by natural order of keys
synchronized
null keys or null values
Iterator

Map implementations returns 3 iterators >
map.keySet().iterator()
map.values().iterator()
map.entrySet().iterator()




one null key and many null values
All are Fail-fast



Yes
No
All are Fail-fast



Yes
No
All are Fail-safe

Yes


one null key and many null values
All are Fail-fast


Yes

Null key not allowed,
Allow many null values
All are Fail-fast


Yes
Yes
No
All are Fail-safe


You also must know >

List hierarchy tutorial in java - Detailed - java.util.ArrayList, java.util.LinkedList, java.util.vector, java.util.concurrent.CopyOnWriteArrayList classes


Set hierarchy tutorial in java - Detailed - java.util.HashSet, java.util.concurrent.CopyOnWriteArraySet, java.util.LinkedHashSet, java.util.TreeSet, java.util.concurrent.ConcurrentSkipListSet, java.util.EnumSet classes


Map hierarchy tutorial in java - Detailed - java.util.HashMap, java.util.Hashtable, java.util.concurrent.ConcurrentHashMap, java.util.LinkedHashMap, java.util.TreeMap, java.util.concurrent.ConcurrentSkipListMap, java.util.IdentityHashMap, java.util.WeakHashMap, java.util.EnumMap classes





Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.


/** Copyright (c), AnkitMittal JavaMadeSoEasy.com */
.

RELATED LINKS>

Collection in java





eEdit
Must read for you :