In the main method,I have made a list of Person with different ages.Now when I use collect method to transform this list into a list of Persons' ages.The code in BiConsumer combiner function is never reached.
class Person {
private int age;
public int getAge() {
return age;
}
}
//second flavor of collect
ArrayList<Integer> pAges = people.stream()
.collect(ArrayList<Integer>::new,
(listGivenBySupplier, personObjectFromPeopleStream) -> listGivenBySupplier.add(personObjectFromPeopleStream.getAge()),
(r1, r2) -> { //Also please explain what value is passed to r1 and r2
System.out.println("r1: " + r1);
System.out.println("r2: " + r2);
r1.add(2222);
r2.add(2211);
});
System.out.println("pAges:" + pAges);