Get List<K> from HashMap<K, V> where V is instance of I [closed]

Using Java 8 you can do

Map<K, V> map = new HashMap<>();
List<K> list = map.entrySet().stream()
        .filter(e -> e.getValue() instanceof I)
        .map(e -> e.getKey())
        .collect(Collectors.toList());

Leave a Comment