Casting Spliterator<T> and methods signature

Boaz Nahum boaznahum at
Mon Apr 15 07:32:06 PDT 2013

Spliterator *interface *is source-only of  elements, So Intuitively and
formally it can shown that it is safe casting Spliterator<? extends T> to

So, isn't better that methods that accept Spliterator<T> will accept
Spliterator<? extends T> :

public static <T>  Stream<T> stream(Spliterator<? extends T> p1)

This makes user code much cleaner.


More information about the lambda-dev mailing list