user4062
0
Q:

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());
}
3

New to Communities?

Join the community