I'd like to know what is the best way to go about counting stream iterations (if possible). This is the stream I am using:
list.stream().map(o->o.toString()).forEach(System.out::println);
This is my toString method:
@Override
public String toString() {
String string = "something"
return string;
}
What I'm trying to do is also print out a number of iterations, so the list would print out as:
1. List:
something
2. List:
something
I'd definitely have to use stream, toString and forEach, as this is an assignment. I'm just learning how streams work.