ArrayList常用方法:
- public boolean add(E e):将指定的元素追加到此集合的末尾
ArrayList<String> array = new ArrayList<String>();
array.add("hello");
- public void add(int index,E element):在此集合中的指定位置插入指定的元素
ArrayList<String> array = new ArrayList<String>();
array.add(1,"javase");
- public boolean remove(Object o):删除指定的元素,返回删除是否成功
array.remove("world")
- public E remove(int index):删除指定索引处的元素,返回被删除的元素
array.remove(1)
- public E set(int index,E element):修改指定索引处的元素,返回被修改的元素
array.set(1,"javaee")
- public E get(int index):返回指定索引处的元素
array.get(1)
- public int size():返回集合中的元素的个数
array.size()