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 METHOD
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. 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類)這些操作的執行時間和下標值成正比。 因此假如調用者不了解實現方式,通常應該遍歷列表元素,這比指定下標位置更可取。
新聞熱點
疑難解答