|
ArrayList
|
HashMap
|
Interface
|
Implementation
of java.util.List Interface.
|
Implementation
of java.util.Map interface.
|
Storage
|
It
used to store the object.
|
It
is used to store the object in key-value pair.
Where
key and value are different objects.
|
Methods to implement
|
No method is
required to implement.
However contains()
method uses the equals() method to check the existence of the object.
|
For
HashMap, class which is used as key must implements equals() and hashCode()
method correctly.
Better
hashcode() implementation will lead to better performance.
|
Ordering
|
ArrayList
maintain order of object.
|
HashMap
doesn't provide any order guarantee.
|
Duplicate
|
ArrayList
allows duplicates
|
HashMap
doesn't allow duplicates key, though it allows duplicate values.
|
Resizing
|
Size
increase 50% after resizing.
|
Size
increase 100%. Load factor plays the vital role to resize the HashMap.
|
Wednesday 18 November 2015
ArrayList vs HashMap in Java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment