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

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

$
0
0
/** * This method gets the Key for the given Value * @param paramName * @return */private String getKeyForValueFromMap(String paramName) {    String keyForValue = null;    if(paramName!=null)) {        Set<Entry<String,String>> entrySet = myMap().entrySet();        if(entrySet!=null && entrySet.size>0) {            for(Entry<String,String> entry : entrySet) {                if(entry!=null && paramName.equalsIgnoreCase(entry.getValue())) {                    keyForValue = entry.getKey();                }            }        }    }    return keyForValue;}

Viewing all articles
Browse latest Browse all 41

Trending Articles



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