Arrays.stream() vs Stream.of()

Paul Sandoz paul.sandoz at oracle.com
Thu Aug 22 05:29:45 PDT 2013


On Aug 22, 2013, at 12:19 PM, Richard Warburton <richard.warburton at gmail.com> wrote:

> Hi,
> 
> I'm assuming that you prefer the Stream.of methods.  Are you proposing
>> that the Arrays.stream methods should be removed?
>> 
> 
> Essentially yes, though I think your email certainly raises some good
> points.
> 

Note that the Arrays.parallelStream methods were removed a while ago, but the other argument about the range still holds.

I guess i am OK with this duplication. 

The primary use-case for Stream.of was for creating a stream from a list of literal values,  even though an array can be passed instead (a bit like Arrays.asList(), but now we have static methods on interfaces we can provide a better location).

It would look odd if we remove Arrays.stream(T[] array)) but kept the range variant.

If we remove both there might be some bemusement about how to create streams from arrays since Arrays is a logical place to look.

Perhaps we can provide some additional documentation on Stream.of(T... values) methods referring to Arrays.stream for those that need to use a range?

Paul.


More information about the lambda-dev mailing list