I understand that Java 8 Stream provides a method .collectfor converting a stream to any collection / data structure of our choice and is very general. Understand that Stream can be created from a non-collection / resouce object. But in terms of usage, it’s natural to convert Stream to List / Set.
Stream already provides a method toArray()for converting to an array, so why not toList()and toSet()?
source
share