Question from the Java and Craftsmanship test

Find the maximum age of employees in a mall.

Medium

Given this structure

record Mall(Collection<Shop> shops) {}

record Shop(Collection<Employee> employees) {}

record Employee(int age) {}

And this code

Shop firstShop = new Shop(List.of(new Employee(15), new Employee(17)));
Shop secondShop = new Shop(List.of(new Employee(12), new Employee(40)));

int result = new Mall(List.of(firstShop, secondShop))
    .shops()
    .stream()
    .flatMap(shop -> shop.employees()
        .stream()
        .map(Employee::age))
    .mapToInt(Integer::valueOf)
    .max()
    .orElseThrow();

What is the value of result?

Author: Clément DevosStatus: PublishedQuestion passed 265 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!