Question from the Java test

How to convert a Stream<Integer> to an array of Integer in Java

Expert

Given a variable myStream of type Stream<Integer>, the following code

Integer[] positive = stream.filter(i -> i >= 0).toArray(size -> new Integer[size]);  
Integer[] negative = stream.filter(i -> i < 0).toArray(size -> new Integer[size]);  
Author: LoïcStatus: PublishedQuestion passed 275 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!