This is my hash map:
HashMap<Customer, HashSet<Car>> carsBoughtByCustomers = ...
How can I get a new HashMap that will contain for each customer the amount of cars, i.e. the size of the HashSet?
I want to do this without loops, but using streams only.
My attempt:
HashMap<Customer, Integer> result = (HashMap<Customer, Integer>)
    carsBoughtByCustomers.entrySet().stream()
        .map(e -> e.getValue().size());
 
    