-1

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?

huk12353
  • 23
  • 4
  • 3
    Does this answer your question? [How to calculate the intersection of two sets?](https://stackoverflow.com/questions/8882097/how-to-calculate-the-intersection-of-two-sets) – Amongalen Jan 12 '21 at 12:02

1 Answers1

0
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.

JCWasmx86
  • 3,473
  • 2
  • 11
  • 29