Close

Java 8 Streams - DoubleStream.map Examples

Java 8 Streams Java Java API 


Interface:

java.util.stream.DoubleStream

java.lang.AutoCloseableAutoCloseablejava.util.stream.BaseStreamBaseStreamjava.util.stream.DoubleStreamDoubleStreamLogicBig

Method:

DoubleStream map(DoubleUnaryOperator mapper)

This intermediate operation, returns a stream consisting of the results of applying the given mapper function to the elements of this stream.

Examples


package com.logicbig.example.doublestream;

import java.util.stream.DoubleStream;

public class MapExample {

public static void main(String... args) {
DoubleStream ds = DoubleStream.of(1.0, 1.2, 2.0, 2.4, 3.0);
DoubleStream ds2 = ds.filter(d -> d > 2)
.map(d -> d + 2.5);
ds2.forEach(System.out::println);
}
}

Output

4.9
5.5




See Also