Let us first create a Stream:
Stream<String> stream = Stream.of("Bing Bang Theory", "Vampire Diaries", "Game of Thrones", "Homecoming");
Now convert the above stream to typed array:
final String[] strArr = stream.toArray(String[]::new);
The following is an example to convert Stream to typed array in Java:
import java.util.Arrays; import java.util.stream.Stream; public class Demo { public static void main(String[] args) { Stream<String> stream = Stream.of("Bing Bang Theory", "Vampire Diaries", "Game of Thrones", "Homecoming"); final String[] strArr = stream.toArray(String[]::new); System.out.println("Array..."); Arrays.asList(strArr).forEach(n-> System.out.println(n)); } }
Array... Bing Bang Theory Vampire Diaries Game of Thrones Homecoming