Câu hỏi phỏng vấn Android
Câu hỏi

When to use Sparse...

Câu trả lời

Here is a concise answer to the Android interview question "When to use SparseArray vs HashMap?":

SparseArray

Use SparseArray when:

  • You need to store primitive integer keys and object values
  • You want to optimize memory usage compared to HashMap
  • You are working with a fixed set of keys that are integers

SparseArray is more memory efficient than HashMap for storing integer keys because it avoids the overhead of Integer wrapper objects. It's a good choice when you have a limited set of integer keys.

HashMap

Use HashMap when:

  • You need to store arbitrary key-value pairs
  • You want the f...
senior

senior

Gợi ý câu hỏi phỏng vấn

middle

When to use Android's ArrayMap instead of a HashMap ?

junior

What is the most appropriate way to store user settings in Android application?

expert

When would you use AIDL?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào