IntStream mapToLong(IntToLongFunction mapper)
returns a LongStream consisting of
the results of applying the given function. This is an intermediate operation.
mapToLong
has the following syntax.
LongStream mapToLong(IntToLongFunction mapper)
The following example shows how to use mapToLong
.
import java.util.stream.IntStream; import java.util.stream.LongStream; /*from ww w . ja v a 2 s .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.