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.