This can be done using toArray(String[]::new)
as the terminal operation on the stream.
toArray(size -> new String[size]) or toArray(String[]::new).
To filter out names with length greater than 10 characters -
String[] men = names.stream()
.filter(name -> name.length() > 10)
.toArray(String[]::new);
In this example the terminal method toArray(String[]::new)
converts the resulting array to the String[] type.
We can use the specific type in this method and it will convert it the mentioned type only if it is possible to do so.