关于arraylist一个简单问题,立刻给分

来源:百度知道 编辑:UC知道 时间:2024/05/24 04:04:02
arraylist的addAll(int index, Collection<? extends E> c)方法中的
(Collection<? extends E> c)是什么,最好给个例子

System.Collections.ArrayList类是一个特殊的数组。通过添加和删除元素,就可以动态改变数组的长度。
一.优点

1。支持自动改变大小的功能
2。可以灵活的插入元素
3。可以灵活的删除元素

二.局限性

跟一般的数组比起来,速度上差些

三.添加元素

1.public virtual int Add(objectvalue);

将对象添加到ArrayList的结尾处

ArrayListaList=newArrayList();
aList.Add("a");
aList.Add("b");
aList.Add("c");
aList.Add("d");
aList.Add("e");
内容为abcde

2.public virtual void Insert(intindex,objectvalue);

将元素插入ArrayList的指定索引处

ArrayListaList=newArrayList();
aList.Add("a");
aList.Add("b");
aList.Add("c");
aList.Add("d");
aList.Add("e");
aList.Insert(0,"aa");

结果为aaabcde

3.public virtual void InsertRange(intindex,ICollectionc);

将集合中的某个元素插入ArrayList的指定索引处

ArrayListaList=newArrayList();
aList.