LongStream toArray()
returns an array containing the elements of this stream.
This is a terminal operation.
toArray
has the following syntax.
long[] toArray()
The following example shows how to use toArray
.
import java.util.stream.LongStream; // ww w .j a v a 2s . c om public class Main { public static void main(String[] args) { LongStream b = LongStream.of(1L, 1L, Long.MAX_VALUE, Long.MIN_VALUE); long[] l = b.toArray(); for(long v:l){ System.out.println(v); } } }
The code above generates the following result.