richersoon richersoon - 5 months ago 11
Java Question

Simpliest way to convert array of Integer to array of String in Java 8

I would like to convert an

Integer[]
but
toArray()
is giving me
Object[]
. How can I convert it to
String[]
?

Stream.of(ids).map(String::valueOf).toArray();

Answer
String[] array = Stream.of(ids).map(String::valueOf).toArray(String[]::new);
Comments