Varargs stream factory methods
    Brian Goetz 
    brian.goetz at oracle.com
       
    Sat Apr 20 08:46:10 PDT 2013
    
    
  
Currently we have, in Arrays:
     public static <T> Stream<T> stream(T[] array) {
         return stream(array, 0, array.length);
     }
     public static IntStream stream(int[] array) {
         return stream(array, 0, array.length);
     }
etc.
We *could* make these varargs methods, which is useful as creating 
ad-hoc stream literals:
   Arrays.stream(1, 2, 4, 8).map(...)
The downside is that we would have to lose (or rename) methods like:
     public static IntStream stream(int[] array,
                                    int fromIndex, int toIndex) {
since stream(1, 2, 3) would be ambiguous.
Probably better, make these static factories in the various stream 
interfaces:
   Stream.of("foo", "bar")
   IntStream.of(1, 2, 4, 8)
    
    
More information about the lambda-libs-spec-observers
mailing list