How do I convert a list of String into an array? The following code returns an error.
public static void main(String[] args) { List strlist
List.toArray() necessarily returns an array of Object. To get an array of String, you need to use the casting syntax:
List.toArray()
String[] strarray = strlist.toArray(new String[0]);
See the javadoc for java.util.List for more.