@Test
public void r(){
List<Person> javaProgrammers = new ArrayList<Person>() {
{
add(new Person("Elsdon", "1", "Java programmer", "male", 43, 2000));
add(new Person("Elsdon", "1", "Java programmer", "female", 23, 1500));
add(new Person("Elsdon", "Jaycob", "Java programmer", "male", 33, 1800));
add(new Person("Elsdon", "Jaycob", "Java programmer", "female", 32, 1600));
add(new Person("Elsdon", "Jaycob", "Java programmer", "male", 22, 1200));
add(new Person("Maude", "2", "Java programmer", "female", 27, 1900));
add(new Person("Maude", "2", "Java programmer", "male", 30, 2300));
add(new Person("Maude", "Jaimie", "Java programmer", "female", 35, 1700));
add(new Person("Maude", "Jaimie", "Java programmer", "male", 33, 2000));
add(new Person("Maude", "Jaimie", "Java programmer", "female", 34, 1300));
}
};
List<Person> phpProgrammers = new ArrayList<Person>() {
{
add(new Person("Jarrod", "Pace", "PHP programmer", "male", 34, 1550));
add(new Person("Clarette", "Cicely", "PHP programmer", "female", 23, 1200));
add(new Person("Victor", "Channing", "PHP programmer", "male", 32, 1600));
add(new Person("Tori", "Sheryl", "PHP programmer", "female", 21, 1000));
add(new Person("Osborne", "Shad", "PHP programmer", "male", 32, 1100));
add(new Person("Rosalind", "Layla", "PHP programmer", "female", 25, 1300));
add(new Person("Fraser", "Hewie", "PHP programmer", "male", 36, 1100));
add(new Person("Quinn", "Tamara", "PHP programmer", "female", 21, 1000));
add(new Person("Alvin", "Lance", "PHP programmer", "male", 38, 1600));
add(new Person("Evonne", "Shari", "PHP programmer", "female", 40, 1800));
}
};
Map <String,Map<String,List<Person>>>z=
javaProgrammers.stream().collect(Collectors.groupingBy(t>t.getFirstName(),Collectors.groupingBy(r->r.getLastName())));
z.forEach((k,v)->{
v.forEach((k1,v1)->{
v1.forEach(v2->System.out.println(v2.getFirstName()+v2.getLastName()));
});
});