0 votes
in JAVA by
Which of the following is true about the collect() method in Java 8?

a) It is used to terminate the stream and return a single result.

b) It is used to perform a side-effect on each element of the stream.

c) It is used to transform each element of the stream into a new element.

d) It is used to accumulate the elements of the stream into a collection.

1 Answer

0 votes
by

Answer: d) It is used to accumulate the elements of the stream into a collection.

Explanation: The collect() method allows you to accumulate the elements of a stream into a collection, using a Collector. For example, you can use collect() to create a list, set, or map from a stream of elements.

...