Question

In my Android application I have used Hash maps in many situations. And I was asked to use sparse arrays by concerning the performance of the application. So, how sparse array differs from a hashmap in java and what are the advantages of sparse array over hashmap . Thank You.

Was it helpful?

Solution

I beleive the description of sparse array clearly mentions the difference:

It is intended to be more memory efficient than using a HashMap to map Integers to Objects, both because it avoids auto-boxing keys and its data structure doesn't rely on an extra entry object for each mapping.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top