+ 2
What is the difference between HashMap and ArrayList
3 ответов
+ 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
+ 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
- 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