Skip to content

Instantly share code, notes, and snippets.

@theboreddev
Created July 18, 2020 20:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save theboreddev/298f3da0a326da33022b0dc97e549343 to your computer and use it in GitHub Desktop.
Save theboreddev/298f3da0a326da33022b0dc97e549343 to your computer and use it in GitHub Desktop.
youngestEmployeeBySex
final Map<Employee.Sex, Optional<Employee>> youngestEmployeeBySex = employees.stream()
.collect(groupingBy(Employee::getSex, minBy(comparing(Employee::getAge))));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment