In my previous question - How to filter the age while grouping in map with list I was able to find the name to age groups using List users. Now I am
List users
You're after the partitioningBy collector:
partitioningBy
Map> result = users.stream().collect(partitioningBy(u -> u.getAge() > 21));
Then use it as follows:
List userAboveThreshold = result.get(true); List userBelowThreshold = result.get(false);