List<String> list = ..;
String[] array = list.toArray(new String[list.size()]);
The toArray() method without passing any argument returns Object[]. So you have to pass an array as an argument, which will be filled with the data from the list, and returned. You can pass an empty array as well, but you can also pass an array with the desired size.
参考:
http://stackoverflow.com/questions/4042434/convert-string-arraylist-to-string-array-in-java
本文介绍如何将Java中的List<String>转换为String数组。通过使用toArray方法并传递一个指定大小的新数组作为参数,可以有效地完成这一转换过程。
116

被折叠的 条评论
为什么被折叠?



