There are two collections :-
c1 = which include all female employee
c2= all employee whose age greater than 40(age>40).
How can i find all female employee whose age greater than 40?
There are two collections :-
c1 = which include all female employee
c2= all employee whose age greater than 40(age>40).
How can i find all female employee whose age greater than 40?
c1.stream().filter(c2::contains).collect(Collectors.toList());//Last step is optional. Only use it, if you want a list of it.
stream()
: Create a stream out of the first collection. (Java 8+)
Then filter()
by those that are in c2,too.
And then optionally make a list from it.