سؤال

What would streamToArray need to do in the following code?

IntStream stream = IntStream.range(0, 3);
int[] array = streamToArray(stream); // array = [0, 1, 2]
هل كانت مفيدة؟

المحلول

IntStream has the member method toArray, that does exactly what you need:

IntStream stream = IntStream.range(0, 3);
int[] array = stream.toArray();
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top