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

When is it necessary, or better to use a SurfaceView instead of a View ?

junior

What is an AsyncTask ?

expert

What happens if the user navigates away or closes the app while I still have a reference to the Activity
the user just closed in my AsyncTask ?

Bình luận

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

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