Overview Package Class Use Tree Deprecated Index Help JavaTM 2 Platform
Std. Ed. v1.4.2 PREV CLASS NEXT CLASSFRAMES NO FRAMES All Classes SUMMARY: NESTED FIELD CONSTR METHODDETAIL: FIELD CONSTR METHODjava.util
Interface ListAll Superinterfaces: Collection All Known Implementing Classes: AbstractList, ArrayList, LinkedList, Vector public interface List extends CollectionAn ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can Access elements by their integer index (position in the list), and search for elements in the list. 有序的集合(也被称为sequence)。该接口的用户可以精确控制列表元素插入的位置。 用户可以通过整数下标(列表中的位置)访问、查找列表中的元素。
Unlike sets, lists typically allow duplicate elements. More formally, lists typically allow pairs of elements e1 and e2 sUCh that e1.equals(e2), and they typically allow multiple null elements if they allow null elements at all. 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. 和set不同,列表通常答应重复元素。也就是说,列表通常答应e1.equals(e2)这样的 元素对e1和e2,假如答应null元素的话,通常也答应重复的null元素。 假如有人希望实现list而当用户试图插入重复元素时抛出运行时异常来禁止重复,这是不可思议的, 我们希望这样的用法极少。
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. 对于iterator、add、remove、equals和hashCode方法,除了遵守Collection接口中指定的 以外,List接口还提供了额外的约定。按照惯例,还包括其他继续来的方法声明。
The List interface provides four methods for positional (indexed) access to list elements. Lists (like Java arrays) are zero based. Note that these operations may execute in time proportional to the index value for some implementations (the LinkedList class, for example). Thus, iterating over the elements in a list is typically preferable to indexing through it if the caller does not know the implementation. List接口提供了一些通过下标访问列表元素的四个可选方法。List和Java数组一样,是基于0的。 注重对于某些实现(比如LinkedList类)这些操作的执行时间和下标值成正比。 因此假如调用者不了解实现方式,通常应该遍历列表元素,这比指定下标位置更可取。