ArrayList集合常用方法——每天一个Java小技巧
其他
2020-05-02 02:58:55
阅读次数: 0
ArrayList构造方法和添加方法
方法名 |
说明 |
public ArrayList() |
创建一个空的集合对象 |
public boolean add(E e) |
将指定的元素追加到此集合的末尾 |
public void add(int index,E element) |
在此集合中的指定位置插入指定的元素 |
ArrayList集合常用方法
方法名 |
说明 |
public boolean remove(Object o) |
删除指定的元素,返回删除是否成功 |
public E remove(int index) |
删除指定索引处的元素,返回被删除的元素 |
public E set(int index,E element) |
修改指定索引处的元素,返回被修改的元素 |
public E get(int index) |
返回指定索引处的元素 |
public int size() |
返回集合中的元素的个数 |
转载自blog.csdn.net/xiaozhezhe0470/article/details/105868743