public static void main(String[] args) {
String[] strings = new String[]{
"0", "0", "0", "0"
};
List<String> strings1 = Arrays.asList(strings);
strings1.add("1212");
ArrayList arrayList = new ArrayList<String>();
for (String s : strings1) {
arrayList.add(s);
}
System.out.println(arrayList);
}
数组转集合 不可以直接进行对集合进行操作 抛出RunTime异常
最新推荐文章于 2025-12-11 08:58:14 发布
此篇博客介绍了如何使用Java的ArrayList将字符串数组转换为List,并向其中添加新的元素'1212',最后输出整个列表的内容。
5426

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



