LongStream map(LongUnaryOperator 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.
LongStream map(LongUnaryOperator mapper)
- LongStream : A sequence of primitive Long-valued elements.
- LongUnaryOperator : An operation on a single long-valued operand that produces an long-valued result.
- mapper : A stateless function which is applied to each element and the function returns the new stream.
Return Value : LongStream map(LongUnaryOperator mapper) returns a stream by applying the given function.
Example 1 : Using LongStream map() to get the negative of square of elements of LongStream.
-16 -25 -36 -49
Example 2 :Using LongStream map() to get the half of elements of LongStream in given range.
1 1 2 2 3
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- LongStream flatMap(LongFunction mapper) in Java
- IntStream map(IntUnaryOperator mapper) in Java
- IntStream flatMap(IntFunction mapper) in Java
- DoubleStream flatMap(DoubleFunction mapper) in Java
- DoubleStream map(DoubleUnaryOperator mapper) in Java
- Java | Collectors averagingLong (ToLongFunction mapper) with Examples
- LongStream.Builder build() in Java
- java.util.stream.IntStream/LongStream | Search an element
- LongStream sum() in Java
- LongStream generate() method in Java
- LongStream parallel() in Java
- LongStream peek() in Java with examples
- LongStream rangeClosed() in Java
- LongStream range() in Java
- LongStream sequential() in Java
- LongStream skip() in Java
- LongStream sorted() in Java
- LongStream summaryStatistics() in Java
- LongStream average() in Java with Examples
- LongStream concat() in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.