I have searched for this, but unfortunately, I don\'t get the correct answer.
class Helper { public static T[] toArray(List list) {
See Guava's Iterables.toArray(list, class).
Iterables.toArray(list, class)
Example:
@Test public void arrayTest() { List source = Arrays.asList("foo", "bar"); String[] target = Iterables.toArray(source, String.class); }