Java Hashmap: How to get key from value?

前端 未结 30 1758
忘掉有多难
忘掉有多难 2020-11-22 02:14

If I have the value \"foo\", and a HashMap ftw for which ftw.containsValue(\"foo\") returns true, how can I

30条回答
  •  有刺的猬
    2020-11-22 03:09

    It sounds like the best way is for you to iterate over entries using map.entrySet() since map.containsValue() probably does this anyway.

提交回复
热议问题