gpt4 book ai didi

Java 将 ArrayList 转换为 String[][]

转载 作者:行者123 更新时间:2023-12-02 20:35:54 24 4
gpt4 key购买 nike

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

最佳答案

只需以数组形式获取内容

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

关于Java 将 ArrayList<String[]> 转换为 String[][],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20832814/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com