0 votes
in JAVA by

What is the purpose of the peek() method in a stream pipeline?

a) To modify the stream elements

b) To inspect the stream elements

c) To terminate the stream

d) To filter the stream elements

1 Answer

0 votes
by

Answer: b) To inspect the stream elements.

Explanation: The peek() method allows you to perform a side-effect on each element of the stream without modifying the stream itself.

...