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

What does LayoutInflater in Android do?

middle

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

junior

What is Armv7?

Bình luận

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

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