Which of the following stream operations is a terminal operation?

  • collect()
  • filter()
  • forEach()
  • mapToDouble()
In Java Streams API, a terminal operation is an operation that produces a result or a side-effect. The collect() method is a terminal operation that collects the elements of a stream into a new collection or performs some other final action. Options 1 to 3 are intermediate operations, which transform or filter the elements but do not terminate the stream.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *