What is the difference between HashMap and ArrayList | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the difference between HashMap and ArrayList

20th Jul 2017, 8:38 AM
Ishaq Za'rour
3 Answers
+ 1
ArrayList maintains the insertion order while HashMap doesn’t. Which means ArrayList returns the list items in the same order in which they got inserted into the list. On the other side HashMap doesn’t maintain any order, the returned key-values pairs are not sorted in any kind of order. HashMap also uses a lot more space as it saves the values as pairs(key and value) in comparision to arraylist
20th Jul 2017, 8:57 AM
Nirmal Kumar Bhakat
Nirmal Kumar Bhakat - avatar
+ 1
So an arraylist maintains less storage and maintains order while hashmap doesnt have any order and takes a larger space becuase it uses a key and vlaue
20th Jul 2017, 9:22 AM
Ishaq Za'rour
- 1
one is dynamicly expandable on different levels and can have multiple assignments for each position, this is a hashmap. an array is strict, ordered, and quick
20th Jul 2017, 9:02 AM
Solomon Bush
Solomon Bush - avatar