IntStream map(IntUnaryOperator 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.
IntStream map(IntUnaryOperator mapper)
- IntStream : A sequence of primitive int-valued elements.
- IntUnaryOperator : An operation on a single int-valued operand that produces an int-valued result.
- mapper : A stateless function which is applied to each element and the function returns the new stream.
Return Value : IntStream map(IntUnaryOperator mapper) returns a stream by applying the given function.
Example 1 : Using IntStream map() to get the negative of square of elements of IntStream.
-16 -25 -36 -49
Example 2 :Using IntStream map() to get the half of elements of IntStream in given range.
1 1 2 2 3
- IntStream flatMap(IntFunction mapper) in Java
- DoubleStream map(DoubleUnaryOperator mapper) in Java
- LongStream map(LongUnaryOperator mapper) in Java
- LongStream flatMap(LongFunction mapper) in Java
- DoubleStream flatMap(DoubleFunction mapper) in Java
- Java | Collectors averagingLong (ToLongFunction mapper) with Examples
- IntStream of() in Java
- IntStream sum() in Java
- IntStream skip() in Java
- IntStream iterator() in Java
- IntStream asDoubleStream() in Java
- IntStream rangeClosed() in Java
- IntStream mapToDouble() in Java
- IntStream mapToObj() in Java
- IntStream boxed() 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 firstname.lastname@example.org. 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.