get string value from HashMap depending on key name

前端 未结 10 2020
误落风尘
误落风尘 2020-11-28 21:39

I have a HashMap with various keys and values, how can I get one value out?

I have a key in the map called my_code, it should contain a str

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 22:09

    You can use the get(Object key) method from the HashMap. Be aware that i many cases your Key Class should override the equals method, to be a useful class for a Map key.

提交回复
热议问题