java有两种方法添加一组元素
第一种 Arrays.asList( )
String ins = "a,b,c,d,e,f";
String[] insarray = ins.split(",");
List<String> alist = Arrays.asList(insarray);
注意alist不可以进行新增、删除元素,jvm会报错。Unsupported Operation" error at run time.
第二种方式Collections.addAll( )
Collection<Integer> collection =
new ArrayList<Integer>(Arrays.asList(1, 2, 3, 4, 5));
Integer[] moreInts = { 6, 7, 8, 9, 10 };
Collections.addAll(collection, moreInts );
表示向collection集合中添加一组数据moreInts 。