Which of the following methods can be used to create a stream from a collection?

  • filter()
  • forEach()
  • mapToDouble()
  • stream()
You can create a stream from a collection in Java using the stream() method. This method is available on all collections and provides a way to obtain a stream that allows you to perform various stream operations on the elements of the collection. Options 2 to 4 are not used to create streams but for other stream operations.
Add your answer
Loading...

Leave a comment

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