java hashmap get keys by values

Solutions on MaxInterview for java hashmap get keys by values by the best coders in the world

showing results for - "java hashmap get keys by values"
Lisa
28 Mar 2020
1    Map<String, String> map = new HashMap<String, String>();
2    
3    map.put("abc", "123");
4    map.put("xyz", "456");
5    
6    for(Entry<String, String> entry : map.entrySet()) {
7        if(entry.getValue().equalsIgnoreCase("456")) {
8            System.out.println(entry.getKey());
9        }
10    }
11