list的API 如下:

下面是我对这段API的翻译

An ordered collection (also known as a sequence).
一个有序的集合(也被称为序列)
The user of this interface has precise control over where in the list each element is inserted.
这个接口的 使用者对list中每个元素的插入位置有着准确的控制。
The user can access elements by their integer index (position in the list), and search for elements in the list.
使用者可以通过索引(Interger类型)来获取元素,查找元素。 Unlike sets, lists typically allow duplicate elements.
和set不同,list允许重复元素。
More formally, lists typically allow pairs of elements e1 and e2 such that e1.equals(e2),
更正式的说法是,list允许e1.equals(e2),
and they typically allow multiple null elements if they allow null elements at all.
同样,list中也允许存在null元素。
It is not inconceivable that someone might wish to implement a list that prohibits duplicates, by throwing runtime exceptions when the user attempts to insert them, but we expect this usage to be rare.
当然,用户可以自定义list,使得这个list不接受null元素(元素是null就抱空指针错误或者做其他处理)。 The List interface places additional stipulations,beyond those specified in the Collection interface, on the contracts of the iterator, add, remove, equals, and hashCode methods.
Declarations for other inherited methods are also included here for convenience.
除了collection接口中明确需要继承的方法(iterator,add,remove,equals,hashcode)之外,list接口还增加了其他的接口,这些接口为list的使用提供了便利。 The List interface provides four methods for positional (indexed) access to list elements.
list接口提供了四个方法来通过索引获取元素。
Lists (like Java arrays) are zero based.
list和java中的数组一样是从零开始。
Note that these operations may execute in time proportional to the index value for some implementations (the LinkedList class, for example).
需要注意的是这些操作执行的时间可能跟index的值成比例(比如LinkedList )
Thus, iterating over the elements in a list is typically preferable to indexing through it if the caller does not know the implementation.
因此,如果调用者不知道实现,则通过迭代列表中的元素通常优先于索引。 The List interface provides a special iterator, called a ListIterator,
list接口提供了一个特殊的迭代器,称为ListIterator.
that allows element insertion and replacement, and bidirectional access in addition to the normal operations that the Iterator interface provides.
这允许元素插入和替换,以及Iterator接口提供的常规操作之外的双向访问。
A method is provided to obtain a list iterator that starts at a specified position in the list.
从一个list中的特定位置开始的Iterator可以通过list中提供的方法获取。 The List interface provides two methods to search for a specified object.
list接口提供两个方法来查找指定的对象。
From a performance standpoint, these methods should be used with caution.
为了性能要求,这些方法必须使用警告。
In many implementations they will perform costly linear searches.
在很多实现中,他们都是非常耗时的线性查找。 The List interface provides two methods to efficiently insert and remove multiple elements at an arbitrary point in the list.
List接口提供了两种方法,可以在列表中的任意点高效地插入和删除多个元素。 Note: While it is permissible for lists to contain themselves as elements, extreme caution is advised: the equals and hashCode methods are no longer well defined on such a list.
注意:尽管列表允许将其自身作为元素,但建议您非常小心:equals和hashCode方法在这样的列表中不再被很好地定义。 Some list implementations have restrictions on the elements that they may contain.
有一些list的实现在它们能够包含的元素上有一些限制。
For example, some implementations prohibit null elements, and some have restrictions on the types of their elements.
比如,有些list不能有null元素,有些list的元素类型被限制。
Attempting to add an ineligible element throws an unchecked exception, typically NullPointerException or ClassCastException.
尝试将不符合要求的元素加入到list中会抛出异常,通常是空指针异常 或者 ClassCastException。
Attempting to query the presence of an ineligible element may throw an exception, or it may simply return false;
尝试查询一个不符合要求的元素
some implementations will exhibit the former behavior and some will exhibit the latter.
有些实现会禁止之前的行为,有些则会禁止某些字母。
More generally, attempting an operation on an ineligible element whose completion would not result in the insertion of an ineligible element into the list may throw an exception or it may succeed, at the option of the implementation.
通常,尝试操作不符合要求的元素将不会导致不符合要求的元素插入到队列中,而是导致异常,当然也有可能成功,这取决于具体的实现。
Such exceptions are marked as "optional" in the specification for this interface.
在这个接口规范中这些异常被标注为可选择的。 This interface is a member of the Java Collections Framework.
这个接口是java集合框架中的一员。

总结一下,主要说了以下几点:
1、list是一个有序的集合(也是被称为序列),和set不一样,list中允许重复元素的存在。

2、list的使用者对元素的插入位置(索引)有着准确的控制,通过索引可以获取元素。

3、list提供了各种方法来方便我们对其中的元素操作

4、list是java集合框架的一员

说得太笼统,具体还是需要看API。

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

接口中定义的方法

    //返回list中的元素个数
int size(); //判断list中是否包含元素,如果不包含返回true
boolean isEmpty(); //判断list中是否包含某个特定的对象
boolean contains(Object o); //以正确的顺序返回list中元素的迭代器
Iterator<E> iterator(); //返回一个包含list中所有元素的数组,数组中元素的顺序和list中的顺序一样
//这个方法可以当做array-based 和 collection-based API之间的桥梁
Object[] toArray(); //返回一个包含list中所有元素的数组,数组中元素的顺序和list中的顺序一样
//array数组的类型是确定的。如果指定的array大小不足,这个方法将会生成一个新的数组用于返回
//新数组的类型和运行时的数组类型一样
<T> T[] toArray(T[] a); //在list的末尾插入元素(实现类可以选择插入的位置)
boolean add(E e); //如果指定元素存在list中,移除list中第一次出现的指定元素(实现类可以选择具体的实现)
boolean remove(Object o); //判断list中是否包含某个集合
boolean containsAll(Collection<?> c); //将指定集合中的所有元素加到list的末尾
boolean addAll(Collection<? extends E> c); //在指定位置插入指定集合
boolean addAll(int index, Collection<? extends E> c); //删除list中包含的Collection中的所有元素
boolean removeAll(Collection<?> c); //保留list中包含的Collection中的所有元素
boolean retainAll(Collection<?> c); //将该列表的每个元素替换为将该运算符应用于该元素的结果。
default void replaceAll(UnaryOperator<E> operator); //对list中的元素排列
default void sort(Comparator<? super E> c); //删除list中的所有元素
void clear(); boolean equals(Object o); int hashCode(); //根据索引获取list中的元素
E get(int index); //用指定元素替换指定位置上的元素
E set(int index, E element); //在指定位置上增加指定元素
void add(int index, E element); //删除指定索引上的元素
E remove(int index); //获取对象的第一个索引
int indexOf(Object o); //获取对象的最后一个索引
int lastIndexOf(Object o); //返回list的list 迭代器
ListIterator<E> listIterator(); //从指定位置返回list的迭代器
ListIterator<E> listIterator(int index); //返回list的子list
List<E> subList(int fromIndex, int toIndex); //Creates a {@link Spliterator} over the elements in this list.
default Spliterator<E> spliterator()

java.util.List API解读的更多相关文章

  1. Java Concurrency - java.util.concurrent API Class Diagram

    摘自: www.uml-diagrams.org Here we provide several UML class diagrams for the Java™ 7 java.util.concur ...

  2. Java.util.properties读取配置文件分析

    Java.util.properties API链接: https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html Clas ...

  3. 深入分析Java的内置日志API(java.util.logging)(一)

    简介   任何的软件系统,日志都是非常重要的一部分.良好统一的日志规范会大大提高应用程序的可维护性.可靠性,并进而提高开发效率,指导业务.在早期,Java工程师往往都是利用 System.err.pr ...

  4. Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.Exec

    Error:Execution failed for task ':app:transformClassesWithDexForDebug'.> com.android.build.api.tr ...

  5. 【spring mvc】后台API查询接口,get请求,后台Date字段接收前台String类型的时间,报错default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'createDate';

    后台API查询接口,get请求,后台Date字段接收前台String类型的时间筛选条件 后台接口接收 使用的实体 而createDate字段在后台实体中是Date类型 报错信息: org.spring ...

  6. Java8 流式 API(`java.util.stream`)

    熟悉 ES6 的开发者,肯定对数组的一些方法不是很陌生:map.filter 等.在对一组对象进行统一操作时,利用这些方法写出来的代码比常规的迭代代码更加的简练.在 C♯ 中,有 LINQ 来实现.那 ...

  7. java.util.Date和jdk1.8新时间API比拼

    旧的时间和日期的API的缺陷 Java 的 java.util.Date 和 java.util.Calendar 类易用性差,不支持时区,而且都不是线程安全的. Date如果不格式化,打印出的日期可 ...

  8. java.util.concurrent包API学习笔记

    newFixedThreadPool 创建一个固定大小的线程池. shutdown():用于关闭启动线程,如果不调用该语句,jvm不会关闭. awaitTermination():用于等待子线程结束, ...

  9. java.io.BufferedWriter API 以及源码解读

    下面是java se 7 API 对于java.io.BufferedWriter 继承关系的描述. BufferedWriter可以将文本写入字符流.它会将字符缓存,目的是提高写入字符的效率. bu ...

随机推荐

  1. Swift 给UITableView 写extension 时 报错 does not conform to protocol 'UITableViewDataSource'

    那是因为你没有实现 数据源和代理方法 实现下就好了 func tableView(_ tableView: UITableView, numberOfRowsInSection section: In ...

  2. 进程与程序 并行 并发 串行 阻塞 join函数

    进程是正在运行的程序,程序是程序员编写的一对代码,也就是一堆字符,当这堆代码被系统加载到内存并执行,就有了进程. (需要注意的是:一个程序是可以产生多个程序,就像我们可以同时运行多个QQ程序一样,会形 ...

  3. JavaScript(JS)之Javascript对象

    简介: 在JavaScript中除了null和undefined以外其他的数据类型都被定义成了对象,也可以用创建对象的方法定义变量,String.Math.Array.Date.RegExp都是Jav ...

  4. Python基础之函数二

    函数的嵌套 通过名字就能理解,函数里是还可以套着函数用的.这么牛,下面就来看看几段代码,看看是怎么回事.注意:函数一定是先定义后使用. x=1234 def f1(): #定义一个主函数 x = 1 ...

  5. 《剑指offer》 二维数组中的查找

    本题目是<剑指offer>中的题目 二维数组中的查找 题目: 在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个 ...

  6. Python字典(Dictionary)

    Python中字典与类表类似,也是可变序列,不过与列表不同,他是无序的可变序列,保存的内容是以键 - 值对的形式存放的.类似我们的新华字典,他可以把拼音和汉字关联起来,通过音节表可以快速的找到想要的字 ...

  7. OrCAD Capture CIS 16.6 快速地编辑Part的引脚名称

    操作系统:Windows 10 x64 工具1:OrCAD Capture CIS 16.6-S062 (v16-6-112FF) 工具2:Excel 参考1:http://www.360doc.co ...

  8. 在lnmp环境下,将原来的PHP7.0升级到PHP7.2

    基础环境: 系统:centos6.8   环境:lnmp 停止PHP7.0的版本,在做如下操作: 1.下载php-7.2.6.tar.bz2软件包放在/opt 路径下 mkdir /usr/local ...

  9. windows解压.tar00文件

    通常是单个文件太大分拆出来的,例如data.tar00, data.tar01, data.tar02等 cmd命令行进入几个tar0x文件所在目录,执行: copy /b data.tar0* da ...

  10. 一个页面中使用多个UEditor

    如何在一个页面中使用多个Ueditor: 引入这些js: <script src="~/Scripts/ueditor/ueditor.config.js"></ ...