0 votes
in JAVA by

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

a) To transform the stream into a new stream

b) To terminate the stream and return a single result

c) To perform a side-effect on each element of the stream

d) To filter the stream elements

1 Answer

0 votes
by
Answer: c) To perform a side-effect on each element of the stream.

Explanation: The forEach() method allows you to perform an action on each element of the stream, without modifying the stream itself.

Related questions

0 votes
asked Apr 26 in JAVA by SakshiSharma
0 votes
asked Apr 30 in JAVA by john ganales
...