DoubleStream map(DoubleUnaryOperator mapper) in Java
DoubleStream map(DoubleUnaryOperator mapper) returns a stream consisting of the results of applying the given function to the elements of this stream. This is an intermediate operation. These operations are always lazy. Intermediate operations are invoked on a Stream instance and after they finish their processing, they give a Stream instance as output.
DoubleStream map(DoubleUnaryOperator mapper)
- DoubleStream : A sequence of primitive double-valued elements.
- DoubleUnaryOperator : An operation on a single double-valued operand that produces an double-valued result.
- mapper : A stateless function which is applied to each element and the function returns the new stream.
Return Value : DoubleStream map(DoubleUnaryOperator mapper) returns a stream by applying the given function.
Example 1 : Using DoubleStream map() to get the negative of square of elements of DoubleStream.
-19.360000000000003 -30.25 -39.69 -50.41
Example 2 :Using DoubleStream map() to get the half of elements of DoubleStream.
1.1 3.65 4.1 0.7