Java 8 Streams Java Java API
java.util.stream.LongStream
LongStream map(LongUnaryOperator mapper)
This intermediate operation, returns a stream consisting of the results of applying the given mapper function to the elements of this stream.
package com.logicbig.example.longstream;import java.util.stream.LongStream;public class MapExample { public static void main(String... args) { LongStream stream = LongStream.of(4, 7, 9, 11, 13, 17); LongStream stream2 = stream.map(MapExample::squared); stream2.forEach(System.out::println); } private static long squared(long operand) { return operand * operand; }}
164981121169289