Java HashMap: How to get a key and value by index?

后端 未结 10 1376
鱼传尺愫
鱼传尺愫 2020-12-28 12:54

I am trying to use a HashMap to map a unique string to a string ArrayList like this:

HashMap>

Basical

10条回答
  •  伪装坚强ぢ
    2020-12-28 13:10

    You can use Kotlin extension function

    fun LinkedHashMap.getKeyByPosition(position: Int) =
            this.keys.toTypedArray()[position]
    
    
    fun LinkedHashMap.getValueByPosition(position: Int) =
            this.values.toTypedArray()[position]
    

提交回复
热议问题