Use a Java Array like a List
You should use the List#toArray method, you want to use the generic method, so not the one returning Object[], for this to work you need to supply an array of the correct size, such that it can store the data there.

List&lt;String&gt; list = ...;
String[] = list.toArray(new String[list.size()]);


Note that the array need not be the same size, there are two cases to consider:


If array.length &lt; list.size(), then it will create a new array and return that one.
Else, it will put the data in the input array.