This post shows the simplest way to convert Java 8 stream to an Array with an example snippet.
How to convert a Java 8 Stream to an Array?
Stream<String> stringStream = Stream.of("a", "b", "c");
String[] stringArray = stringStream.toArray(size -> new String[size]);
Arrays.stream(stringArray).forEach(System.out::println);
Prints:
a
b
c
Comments
Post a Comment