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());
More Related Contents:
- Java 8 Streams: multiple filters vs. complex condition
- Sum values from specific field of the objects in a list
- How to force max to return ALL maximum values in a Java Stream?
- Java 8 Nested (Multi level) group by
- How to convert a Java 8 Stream to an Array?
- Should I return a Collection or a Stream?
- What is difference between Collection.stream().forEach() and Collection.forEach()?
- How to sum a list of integers with java streams?
- Group by and sum objects like in SQL with Java lambdas?
- Why does Stream not implement Iterable?
- How can I create a stream from an array?
- In Java 8, is there a ByteStream class?
- Filter Java Stream to 1 and only 1 element
- Find maximum, minimum, sum and average of a list in Java 8
- Does Java SE 8 have Pairs or Tuples?
- Does Stream.forEach respect the encounter order of sequential streams?
- Why does findFirst() throw a NullPointerException if the first element it finds is null?
- Java streams lazy vs fusion vs short-circuiting
- Collectors.summingInt() vs mapToInt().sum()
- How to check if a Java 8 Stream is empty?
- Stream Way to get index of first element matching boolean
- How to sum values in a Map with a stream?
- When and how does HashMap convert the bucket from linked list to Red Black Trees? [duplicate]
- Is mapToDouble() really necessary for summing a List with Java 8 streams?
- Is it possible to cast a Stream in Java 8?
- ‘Optional.get()’ without ‘isPresent()’ check
- Most elegant way to join a Map to a String in Java 8
- How to apply Filtering on groupBy in java streams
- Group sequences of values
- Java 8 stream map to list of keys sorted by values