RFR: 8180352: Add Stream.toList() method

Brian Goetz brian.goetz at oracle.com
Wed Nov 4 23:02:28 UTC 2020


> I wonder if we should not do the same with toList(), having toList() to be equivalent to collect(Collectors.toUnmodifiableList()) and toList(IntFunction<List<E>>) allowing to use a null friendly List implementation like ArrayList.

If you pull on this string all the way, we end up with "let's just not 
do anything."

Adding conveniences only begets demands for more conveniences, and the 
endpoint there is a class with hundreds of trivial methods. This is why 
we held the line for so long.  Over that time, it emerged that the _one_ 
convenience method we could justify was toList(), since 
collect(toList()) is single most commonly used terminal op -- but only 
if we could justify stopping there.  Which I think we can, so we're 
stopping there.  (Maybe in five years we'll add another one.)




More information about the core-libs-dev mailing list