IntStream mapToLong(IntToLongFunction mapper) example
Description
IntStream mapToLong(IntToLongFunction mapper)
returns a LongStream consisting of
the results of applying the given function. This is an intermediate operation.
Syntax
mapToLong
has the following syntax.
LongStream mapToLong(IntToLongFunction mapper)
Example
The following example shows how to use mapToLong
.
import java.util.stream.IntStream;
import java.util.stream.LongStream;
//from ww w . j ava 2s. c o m
public class Main {
public static void main(String[] args) {
IntStream i = IntStream.of(6,5,7,1, 2, 3, 3);
LongStream d = i.mapToLong(n ->{ return (long)n;});
d.forEach(System.out::println);
}
}
The code above generates the following result.