List中方法的使用
来源:互联网 发布:新加坡留学知乎 编辑:程序博客网 时间:2024/05/22 12:26
总结list的方法:List list = new List();1、list.add()在list中增加一个元素,如果只有list.add(Element el)则自动加在list的最后,并返回一个boolean值而list.add(int index,element el)则表示在index的位置插入一个元素,无返回值。2、list.addAll()用法同上,有list.addAll(Collection c)和list.addAll(int index,collection c)两种,都返回一个boolean值。collection类型扩展自java.util.Collection接口。3、list.get(int index)返回位置是index的一个元素值。4、list.retainAll(Collection c)获得所有c集合里面有的元素。5、list.toArray()把list的所有值返回到一个数组,list.toArray(T[] a) the runtime type of the returned array isthat of the specified array.不知道runtime怎么翻译。 :(6、list.subList(int fromIndex,int toIndex)返回list位置fromIndex和toIndex之间的list。7、list.clear()remove all。8、list.remove(Object o)remove第一个符合o的元素返回boolean9、list.removeAll(Collection c)删除list中所有符合c集合的元素,返回boolean10、list.set(int index,Element el)把位置为index的元素图还成el。返回先前的元素值。11、list.contains(Object o)如果list中包含o,则返回true,同样list.containsAll(Collection c)也是如此。12、list.indexOf(Object o)返回list中o的位置,为int类型。13、list.isEmpty()返回true如果list为空。14、listIterator()返回一个重复出现元素的list,list.listIterator(int index)指从index开始计算重复元素
15、list.size()
返回集合中元素的总个数
0 0
- List中方法的使用
- C#中List的Find方法的使用
- Python中range的使用以及reverse List的方法
- Python中range的使用以及reverse List的方法
- C#中List的Find方法的使用
- STL中list的erase()方法的使用
- C#中List的Find方法的使用
- JAVA中HashMap(哈希表)的使用(List)方法
- List 中使用 MXML 自定义组件的数据项访问方法
- Java 中 List.subList() 方法的使用陷阱
- 使用List中remove方法时需要注意的问题
- 【笔记】java8中List分组方法的使用
- Python中List的list()方法
- list.contains()方法的使用
- list.contains()方法的使用
- java中List.subList方法使用注意
- java中List.subList方法使用注意
- java中List.subList方法使用注意
- C语言 字符数组赋值的方法 整理
- spring与ThreadLocal
- 【来至百度问答】htm中id和name的不同之处
- C++中将数据添加到文件的末尾
- XML解析----JDom解析XML
- List中方法的使用
- 数据结构队列(链式实现)
- 字典转模型
- 正整数的加法分解
- 猴子吃桃问题。
- Java--文件传输
- HDU - 5187 zhx's contest
- 关于ThreadLocal
- 程序员技能层次模型