What's the difference between
? extends Stream<? extends R>
and
Stream<? extends R>
Is <R> Stream<R> flatMap(Function<? super T,? extends Stream<? extends R>> mapper) same as <R> Stream<R> flatMap(Function<? super T, Stream<? extends R>> mapper).
Could you give some examples?
Short answer:
? extends SomeTypeis very different thanSomeType.Longer answer:
The use of
Stream<extends R>asSomeTypeconfuses the example. To answer the question, consider a simpler comparison, for example:? extends IntegerIntegerThe first observation is that
? extends Integeras a type expression can be used only within generic declarations. On the other hand,Integercan be used in many more places.Here are some code examples to help show the difference: