LongStream mapToObj() in Java
LongStream mapToObj() returns an object-valued Stream consisting of the results of applying the given function.
Note : LongStream mapToObj() is a 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.
<U> Stream<U> mapToObj(LongFunction<? extends U> mapper)
- U : The element type of the new stream.
- Stream : A sequence of elements supporting sequential and parallel aggregate operations.
- LongFunction : Represents a function that accepts a long-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.
Example 1 :
11 100 101 110 111
Example 2 :
13 15 17 19 21