Answers for "how can get key of the specific value in hashmap java"

2

java map get the key from value

public static <T, E> Set<T> getKeyByValue(Map<T, E> map, E value) {
    return map.entrySet()
              .stream()
              .filter(entry -> Objects.equals(entry.getValue(), value))
              .map(Map.Entry::getKey)
              .collect(Collectors.toSet());
}
Posted by: Guest on March-06-2020

Code answers related to "how can get key of the specific value in hashmap java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language