How to use SparseArray

suggest change

Introduction

A SparseArray is an alternative for a Map. A Map requires its keys to be objects. The phenomenon of autoboxing occurs when we want to use a primitive int value as key. The compiler automatically converts primitive values to their boxed types (e.g. int to Integer). The difference in memory footprint is noticeable: int uses 4 bytes, Integer uses 16 bytes. A SparseArray uses int as key value.

Remarks

Advantage :

Disadvantage :

There are several variants of the family like : -SparseArray <Integer, Object> -SparseBooleanArray <Integer, Boolean> -SparseIntArray <Integer, Integer> -SparseLongArray <Integer, Long> -LongSparseArray <Long, Object> -LongSparseLongArray <Long, Long>

SparseArray operations

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents