I have some problems when compiling with flatMap, *Maybe* the signature should be: <R> Stream<R> flatMap(Function<? super T, Stream<? extends R>> mapper); Instead of: <R> Stream<R> flatMap(Function<T, Stream<? extends R>> mapper);