1,http://www.Sina.com /
将数组转换为List后,不能添加或删除List。 只能查一下是否要更改。 否则我就扔例外。 在这种情况下,如果java.util.Arrays.ArrayList中包含java.util.Arrays中的内部类,并且没有重写添加/删除方法,则会调用父类的AbstractList,从而生成父类中的调用迭代器也会报告错误。
公共语音添加(索引,e元素) thrownewunsupportedoperationexception ); }公共移除(索引) thrownewunsupportedoperationexception ); )Arrays.asList(strArray) 方式
将Arrays.aslist(Strarray )返回值从java.util.Arrays.ArrayList转换为java.util.ArrayList。
键码: ArrayList list=new ArrayList (arrays.as list ) Strarray );
ArrayList的构造器
以Collections.addAll(arrayList,strArray )方式转换,根据数组的长度创建相同长度的List,以collections.addall )方式将数组中的元素转换为二进制文件,并将其转换为List
3、集合工具类Collections.addAll()方法
int [ ] a={ 1,2,3 };
列表列表=collection utils.arraytolist (a;
4.使用spring
int [ ] arr={ 1,2,3 }; listintegercollect=arrays.stream (arr ).boxed ).collect (collectors.to list ) ); String[] arr={“1”,“2”; liststringcollect=arrays.stream (arr ).collect (collectors.to list );