Created
July 18, 2020 20:09
-
-
Save theboreddev/d8f8ee3a980b92eff66c95331c9d1da0 to your computer and use it in GitHub Desktop.
groupBySex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final Collection<Employee> employees = List.of( | |
new Employee("Karen Smith", 51200.0, 29, Employee.Sex.FEMALE), | |
new Employee("John Smith", 24000.0, 32, Employee.Sex.MALE), | |
new Employee("Anthony Jackson", 44000.0, 33, Employee.Sex.MALE), | |
new Employee("Alyson Palmer", 34320.0, 36, Employee.Sex.FEMALE), | |
new Employee("Jessica Sanders", 64320.0, 34, Employee.Sex.FEMALE) | |
); | |
final Map<Employee.Sex, List<Employee>> employeesBySex = employees.stream() | |
.collect(groupingBy(Employee::getSex)); | |
System.out.println(employeesBySex); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment