LongStream toArray() example
Description
LongStream toArray()
returns an array containing the elements of this stream.
This is a terminal operation.
Syntax
toArray
has the following syntax.
long[] toArray()
Example
The following example shows how to use toArray
.
import java.util.stream.LongStream;
// www. j av a 2s . c o m
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.