Which method converts a Stream into a List?

  1. toList()
  2. collect(Collectors.toList())
  3. toArray()
  4. convertToList()
Correct answer collect(Collectors.toList())

Explanation

collect(Collectors.toList()) collects stream elements into a List.

Update: Admin added a tag on this question

Topics

By Admin · · 33 views