In my taks I need to find size() of argument and for every object print size. Object of type Car are in Set(so this maybe should help)
I did this:
List<Integer> numberOf = cars .stream .map(car->car.getNumbers().size()) .collect(Collectors.toList()); System.out.println(numberOf);
Output is : [1,1,1,1]
I need output like this:
Audi - 1 Bmw - 1 Porsche - 1 Bentley - 1
If I go with
for(Car c: cars) sout(c.getName + numberOf)
It gets me Audi [1,1,1,1] Bmw[1,1,1,1]etc.
How to properly print all those values. I also tried to Override method toString in class car but I also get the same output.