How sparse array differs from hash map in java

In my Android application, I used hash maps in many situations. And I was asked to use sparse arrays regarding application performance. So how does a sparse array differ from hashmap in java and what are the advantages of a sparse array over hashmap . Thanks.

+4
source share
1 answer

I believe the description of a sparse array clearly indicates the difference:

It is designed for more memory than using HashMap to match Integers in objects, since it avoids the auto-box keys and its data structure does not rely on an additional input object for each match .

For further reading: http://developer.android.com/reference/android/util/SparseArray.html

+5
source

All Articles