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

senior

What are best practices for storing and protecting private API keys in applications?

senior

What is the difference between Android Timer and a Handler to do action every N seconds?

middle

What is the difference between Handler vs AsyncTask vs Thread ?

Bình luận

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

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