IntStream asLongStream()
returns a LongStream consisting of the elements of this stream, converted to long.
This is an intermediate operation.
asLongStream
has the following syntax.
LongStream asLongStream()
The following example shows how to use asLongStream
.
import java.util.stream.IntStream; import java.util.stream.LongStream; /* ww w .j a v a 2 s .c om*/ public class Main { public static void main(String[] args) { IntStream i = IntStream.of(1, 2, 3, 4); LongStream l = i.asLongStream(); l.forEach(System.out::println); } }
The code above generates the following result.