In list find lenghtOfArgument with lambda in Java

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


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.

Read more here:

Content Attribution

This content was originally published by sdavb at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: