集合基础
集合:提供存储空间可变得存储模型,存储的容量发生改变。
ArrayList在util包下,需要导包
ArrayList<E>:可调整大小的数组实现;<E>是一种特殊的数据类型,泛型
在E出现的地方,我们用引用数据类型替换即可;举例ArrayList<String>;ArrayList<student>
public ArrayList() 创建一个空的集合对象
public boolean ArrayList(E e)将指定的元素加到此集合的末尾
true表示添加成功
public void add(int index, E element)在此集合中的指定位置插入指定元素
注意索引不能越界,至多到最后一个索引
public boolean remove(Object o)删除指定元素,返回删除是否成功
public E remove(int index)删除索引处的元素,返回被删除的元素
public E set (int index, E element)修改指定索引处的元