Answers for "how to get the key when you have the value in hashmap java"

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 "how to get the key when you have the value in hashmap java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language