Tuesday, 20 January 2015

Difference between ArrayList and HashMap


Both ArrayList and HashMap belongs to different Collection class in java.Both of them are used to store objects but their internal working is totally different


.                                              ArrayList Vs HashMap





       ArrayList

         HashMap
 Implementation
 ArrayList implements List interface.

 HashMap implements Map interface.
 Storage of Objects
ArrayList only stores one object. 

 HashMap stores tow object one is key and other is value.
Equals and HashCode 


 ArrayList does not have to implements these methods.
 HashMap must implement equals and hashcode method properly.
Order of Insertion 

 ArrayList maintains order of insertion.
 HashMap does not maintains order of insertion.





Happy Reading.Study Well.

No comments:

Post a Comment