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

后端 未结 10 1392
鱼传尺愫
鱼传尺愫 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:33

    Here is the general solution if you really only want the first key's value

    Object firstKey = myHashMap.keySet().toArray()[0];
    Object valueForFirstKey = myHashMap.get(firstKey);
    

提交回复
热议问题