2 Jan 2025
2 Jan 2025
Not Maintained
Insertion order Not Maintained (But keys are Not
Maintained sorted in Maintained
ascending order)
Null
Keys/Values Allowed Allowed Not Allowed Not Allowed
(Null Values are
allowed)
Set will not allow duplicate values to be List will allow duplicate values.
stored.
Accessing elements by their index Accessing elements by index is possible
(position number) is not possible in case in lists.
of sets.
ArrayList (Vs) Vector
ArrayList Vector
ArrayList increases its size every time Vector increases its size every time by
by 50 percent (half). doubling it.
HashMap (Vs) HashTable
HashMap HashTable
HashMap object is not synchronized by Hashtable object is synchronized by
default. default.
In case of a single thread, using HashMap In case of multiple threads, using
is faster than the Hashtable. Hashtable is advisable, with a single
thread, Hashtable becomes slow.
HashMap allows null keys and null values Hashtable does not allow null keys or
to be stored. values.
Comparable (Vs) Comparator
Comparable Comparator
It is used for defining the natural sorting It is used to compare objects in a way that
order of the Object might not align with the natural ordering
[Custom sorting order]