There's more...

The Stream class provides other methods to transform the elements of a Stream:

  • mapToInt(), mapToLong(): These methods are identical to the mapToDouble() method, but they generate IntStream and LongStream objects, respectively.
  • flatMapToDouble(), flatMapToInt(), flatMapToLong(): These methods are identical to the flatMap() method, but they work with DoubleStream, IntStream, and LongStream, respectively.

Get Java 9 Concurrency Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.