Let consider a hashmap
Map id1 = new HashMap();
I inserted some values into both hashmap.
For
Using keySet-
id1.keySet().stream() .filter(x -> x == 1) .map(x -> id1.get(x)) .collect(Collectors.toList())