public class Person {
    public enum Sex {
        MALE, FEMALE
    }

    String name;
    LocalDate birthday;
    Sex gender;
    String emailAddress;

    Person(String n, LocalDate birth, Sex g, String mail) {
        name = n;
        birthday = birth;
        gender = g;
        emailAddress = mail;
    }

    public int getAge() {
        return birthday
                .until(IsoChronology.INSTANCE.dateNow())
                .getYears();
    }

    public void printPerson() {
        System.out.println(name + ", " + this.getAge());
    }

    public static int compareByAge(Person a, Person b) {
        return a.birthday.compareTo(b.birthday);
    }

    public static List<Person> createRoster() {

        List<Person> roster = new ArrayList<>();
        roster.add(
                new Person(
                        "Sylvain",
                        IsoChronology.INSTANCE.date(1984, 5, 13),
                        Person.Sex.MALE,
                        "sylvain@mail.com"));
        roster.add(
                new Person(
                        "Rachida",
                        IsoChronology.INSTANCE.date(1987, 4, 9),
                        Person.Sex.FEMALE, "rachida@mail.com"));
        roster.add(
                new Person(
                        "Adam",
                        IsoChronology.INSTANCE.date(2013, 2, 9),
                        Person.Sex.MALE, "adam@mail.com"));
        roster.add(
                new Person(
                        "Nathan",
                        IsoChronology.INSTANCE.date(2014, 2, 12),
                        Person.Sex.MALE, "nathan@mail.com"));

        return roster;
    }
}

double average = roster.stream()
            .filter(p -> p.getGender() == Person.Sex.MALE)
            .mapToInt(Person::getAge)
            .average()
            .getAsDouble();

double average = roster.parallelStream()
            .filter(p -> p.getGender() == Person.Sex.MALE)
            .mapToInt(Person::getAge)
            .average()
            .getAsDouble();

List<String> namesOfMaleMembersCollect = roster
            .stream()
            .filter(p -> p.getGender() == Person.Sex.MALE)
            .map(p -> p.getName())
            .collect(Collectors.toList());   

Map<Person.Sex, List<Person>> byGender = roster.stream()
                .collect(Collectors.groupingBy(Person::getGender));

List<Map.Entry<Person.Sex, List<Person>>> byGenderList = new ArrayList<>(byGender.entrySet());
byGenderList.stream()
            .forEach(e -> {
                System.out.println("Genre :  " + e.getKey());
                e.getValue()
                    .stream()
                    .map(Person::getName)
                    .forEach(f -> System.out.println(f)); 
           });

Map<Person.Sex, Integer> totalAgeByGender = roster.stream()
                .collect(
                     Collectors.groupingBy(Person::getGender,
                            Collectors.reducing(0, Person::getAge, Integer::sum)
              ));
                
List<Map.Entry<Person.Sex, Integer>> totalAgeByGenderList = new ArrayList<>(totalAgeByGender.entrySet());
                     
totalAgeByGenderList.stream()
            .forEach(e -> 
                System.out.println("Genre: " + e.getKey() +
                    ", Total Age : " + e.getValue()));

public class Averager implements IntConsumer {

    private int total = 0;
    private int count = 0;

    public double average() {
        return count > 0 ? ((double) total) / count : 0;
    }

    @Override
    public void accept(int i) {
        total += i;
        count++;
    }

    public void combine(Averager other) {
        total += other.total;
        count += other.count;
    }
}