Java将ArrayList <String []>转换为String [] []

use*_*284 2 java arrays arraylist

我是否必须遍历每个元素才能转换ArrayList<String[]>String[][]或者是否有更有效的方法?

Sot*_*lis 8

只需将内容作为数组获取

List<String[]> list = new ArrayList<>();
...
String[][] array = list.toArray(new String[0][0]); // the size here is not important, the array is just an indication of the type to use
Run Code Online (Sandbox Code Playgroud)