Why didn't Java choose this signature <T> Stream<T> Stream.generate(Supplier<? extends T> supplier)
over this one <T> Stream<T> Stream.generate(Supplier<T> supplier)
?
I mean the below example (doesn't compile) is correct as a supplier of String
s is also valid in a stream of CharSequence
s, no ?
Supplier<String> constantHello = () -> "Hello";
long count = Stream.<CharSequence>generate(constantHello).count();