Can anyone point to a official Java documentation which describes how many times Stream will invoke each "non-interfering and stateless" intermediate operation for each element.
For example:
Arrays.asList("1", "2", "3", "4").stream()
.filter(s -> check(s))
.forEach(s -> System.out.println(s));
public boolean check(Object o) {
return true;
}
The above currently will invoke check
method 4 times.
Is it possible that in the current or future versions of JDKs the check
method gets executed more or less times than the number of elements in the stream created from List or any other standard Java API?