Hi, All! I have a question on ch4 review q.14. in the Boyarsky/Selikoff OCP review book
The correct answer to q. 14 is D. In option D we have
The answer is correct, however, I think the explanation is incomplete. In the explanation, it states that the reason the above does not compile is because an explicit cast to in is required inside the lambda. While that is true, it's not the only reason that line does not compile. In other words, if you put in the explicit cast, it would STILL not compile because the return type of mapToInt is IntStream, and the above line is trying to assign that to Stream<Integer>, which are incompatible. I think the explanation needs to be updated to include this point to bring attention to return types of mapping functions. This second error can be fixed by either changing the result type to IntStream, or by calling mapToObj on ds.
I could be wrong
. Thank you for reading.