List集合常用方法
1.void add(int index,object ele):在index位置插入ele元素
2.boolean addAll(int index,collection eles):从index位置开始将eles中的所有元素添加进来
3.object get(int index):获取指定index位置的元素
4.int indexof(0bject obj):返回obj在集合中首次出现的位置
5.int lastIndexof(object obj):返回obj在当前集合中末次出现的位置
6.Object remove(int index):移除指定index位置的元素,并返回此元素object 7.set(int index,object ele):设置指定index位置的元素为ele
8.List subList(int fromIndex,int toIndex):返回从fromIndex到toIndex位置的子集合
总结:常用方法
增: add(object obj)末尾添加
删: remove(int index) / remove( object obj)改: set(int index, object ele)
查: get(int index)
插: add(int index, object ele)
长度:size()
遍历: Iterator迭代器方式
增强for循环
普通的循环
笔试题:
区分List中remove(int index)和remove(object obj)