码迷,mamicode.com
首页 > 编程语言 > 详细

Java-集合第三篇List集合

时间:2019-08-20 12:18:25      阅读:73      评论:0      收藏:0      [点我收藏+]

标签:设置   tor   min   返回   java   tin   bsp   ace   rem   

1、List集合

  有序可重复集合,集合中的每个元素都有其对应的顺序索引。

2、List相对于Collection额外提供的方法:

  1》void add(int index,Object element):将元素element插入到List集合的index处。

  2》boolean assAll(int index,Collection c):将集合c所包含的所有元素都插入到List集合的index处。

  3》Object get(int index):返回集合index索引处的元素。

  4》int indexOf(Object o):返回对象o在集合List中第一次出现的位置索引。

  5》int lastIndex(Object o):返回对象o在List集合中最后一次出现的位置索引。

  6》Object remove(int index):删除并返回index索引处的元素。

  7》Object set(int index,Object element):将index索引处的元素替换成element对象,返回被替换的旧元素。

  8》List subList(int fromIndex,int toIndex):返回从索引fromIndex(包含)到索引toIndex(不包含)处所有集合元素组成的子集合。

  与Set相比,List增加了根据索引来插入、替换、删除集合元素的方法。Java 8还为List增加了两个默认方法:

  9》void replaceAll(UnaryOperator operator):根据operator指定的计算规则重新设置List集合的所有元素。

10》void sort(Comparator c):根据Comparator参数对List集合的元素排序。

Java-集合第三篇List集合

标签:设置   tor   min   返回   java   tin   bsp   ace   rem   

原文地址:https://www.cnblogs.com/ZeroMZ/p/11382131.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!