DoubleStream mapToObj() returns an object-valued Stream consisting of the results of applying the given function.
<U> Stream<U> mapToObj(DoubleFunction<? extends U> mapper)
Parameters: This method accepts following parameters:
- U: The element type of the new stream.
- Stream : A sequence of elements supporting sequential and parallel aggregate operations.
- DoubleFunction : Represents a function that accepts an double-valued argument and produces a result.
- mapper : A stateless function to apply to each element.
Return Value: The function returns an object-valued Stream consisting of the results of applying the given function.
Below examples illustrate the mapToObj() method:
Example 1 :
39.303999999999995 91.125 300.76300000000003 704.969
Example 2 :
13.4 14.5 16.7 18.9
Related Articles :
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.