String[] strs = {"a","b","c"};
List list = Arrays.asList(strs);
ArrayList al = new ArrayList(list);
al.add("d");
strs=(String[])al.toArray(new String[0]);
for (int i = 0; i < strs.length; i++) {
System.out.println(strs[i]);
}
List list = Arrays.asList(strs);
ArrayList al = new ArrayList(list);
al.add("d");
strs=(String[])al.toArray(new String[0]);
for (int i = 0; i < strs.length; i++) {
System.out.println(strs[i]);
}
本文介绍了一段Java代码示例,演示了如何将数组转换为List,再从List转换回数组的过程。通过实例展示了使用Java标准库进行数据结构转换的具体步骤。
594

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



