Quantcast
Channel: Java Hashmap: How to get key from value? - Stack Overflow
Viewing all articles
Browse latest Browse all 41

Answer by Amazing India for Java Hashmap: How to get key from value?

$
0
0
public static String getKey(Map<String, Integer> mapref, String value) {    String key = "";    for (Map.Entry<String, Integer> map : mapref.entrySet()) {        if (map.getValue().toString().equals(value)) {            key = map.getKey();        }    }    return key;}

Viewing all articles
Browse latest Browse all 41

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>