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

junior

Is it possible to implement the Model–View–Controller pattern in Java for Android?

middle

What is the difference between invisible and gone for the View visibility status?

expert

When to use AIDL vs Messenger Queue?

Bình luận

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

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