Warning shows when i use Hash Map In android(Use new SparseArray)

后端 未结 4 1383
不知归路
不知归路 2021-01-30 03:01

I am new to developing in android. In my android app I\'m using HashMap, but I\'m getting a warning:

**\"Use new SparseArray(...) ins         


        
4条回答
  •  北荒
    北荒 (楼主)
    2021-01-30 03:45

    It's a hint that there is a better data structure for your code.

    That hint is from Lint. You usually get it when you have a HashMap of integers to something else.

    Its biggest advantage is to treat the integer key as a primitive. In other words, it won't covert to an Integer (the Java object) to use it as a key.

    This is a big deal when using large maps. HashMap will result in the creation of many, many Integer objects in that case.

    See a few more pieces of information here.

提交回复
热议问题