The peek operation is an intermediate operation
the forEach operation, is a terminal operation
the processing order of Collection.stream().forEach() is undefined. so the forEach() is explicitly nondeterministic.
The peek operation is an intermediate operation that allows you to perform an action on each element of a stream as they are consumed from the resulting stream. Unlike the forEach operation, which is a terminal operation that consumes the entire stream and returns void, the peek operation returns a new stream that is identical to the original stream, with the additional side effect of the provided action.
C is the correct answer.
Stream<T> peek(Consumer<? super T> action);
peek is an Intermediate Operation and it returns Stream.
upvoted 3 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
ASPushkin
4 months agoLebannin
1 year, 5 months agoStavok
1 year, 7 months agoStavok
1 year, 6 months agoAnkit1010
1 year, 11 months ago