Answers for "hashmap java how to get the key if we have the value"

0

JAVA HashMap get keys by values

Map<String, String> map = new HashMap<String, String>();
    
    map.put("abc", "123");
    map.put("xyz", "456");
    
    for(Entry<String, String> entry : map.entrySet()) {
        if(entry.getValue().equalsIgnoreCase("456")) {
            System.out.println(entry.getKey());
        }
    }
Posted by: Guest on September-12-2021

Code answers related to "hashmap java how to get the key if we have the value"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language