You nailed it. Even I couldn't figure it out at a glance. So this is what's going on here. You probably know that we have 3 versions of `reduce()`.
And, look at the generics carefully for the below version which is the one that you have used in your code
In your case, 0 is passed as the identity. It's an Integer. Therefore, your `BiFunction` supposed to be `BiFunction<Integer, ? super String, Integer>`
Btw; it's is redundant to use both `parallelStream()` and `parallel()` both together. The end result is however a parallel stream.
The reason we gave two methods to get the same thing is, parallelStream() is defined in Collections interface. That is little bit convenient. Something like we have a forEach() defined for List interface.
OCAJP Java 8, OCPJP Java 8
posted 3 years ago
Thanks a ton Mr. Jude Niroshan!!
Now is clearer, but now I am more scared about the exam if it is supposed for me to know all the signatures of all methods....