The collection and map interfaces are the root interfaces of the collection framework, and the list is the sub-interface of the collection interface, and the list collection represents an ordered, repeatable set of elements
Each element in the collection has its corresponding sequential index. The list collection allows repeating elements to be used to access the collection element at the specified location through an index
Of
List as a sub-interface of the collection interface, you can use all the methods in the collection interface. List is an orderly combination, so the list collection adds a
A method that operates on a collection element according to an index.
Boolean addall (int index, COLLECTION<? extends e> c);
Inserts all the elements in the specified collection into the specified position in the list (optional action). The element that is currently in that position (if any)
And all subsequent elements move to the right (increasing their index). The new elements appear in this column in the order that they are returned by the iterators that specify collection
Table. If the specified collection is modified while the operation is in progress, the behavior of the operation is indeterminate (note that if the specified collection
Is this list, and it is non-empty, this behavior can occur. )
E get (int index);
returns the element at the specified position in the list.
e Set (int index, e element);
replaces the element in the specified position in the list with the specified element (optional action).
list<e> sublist (int fromIndex, int toindex);
Returns a partial view between the specified FromIndex(inclusive) and Toindex(not included) in the list. (If fromIndex and toindex are equal,
The returned list is empty). The returned list is supported by this list, so the non-structural changes in the returned list are reflected in this list, and vice versa. Return
All optional list operations supported by this list are supported in the back-up list.
This method eliminates explicit scope operations, which are typically present for arrays. By passing the sublist view rather than the entire list, the expected list of any
Can be used as a range operation. For example, the following statement removes the range of elements from the list:
List.sublist (from, to). Clear ();
Similar statements can be constructed for indexOf and lastIndexOf , and all algorithms in the collections class can be applied to sublist.
If the support list (that is, this list) is modified from the structure by any other means (rather than by the returned list), the list semantics returned by this method
will become undefined (structural modification refers to changing the size of the list, or otherwise disrupting the list so that the in-progress iteration produces the wrong knot
Results).
The list provides a Listiterator method:
Listiterator<e> Listiterator ();
about the Listiterator interface:
The Listiterator interface adds the following methods based on the iterator interface:
Boolean hasprevious ();
If you traverse the list in reverse, the list iterator has multiple elements and returns true .
E Previous ();
Returns the previous element in the list. You can call this method repeatedly to iterate the list, or mix calls next to move forward and backward (note alternating calls to next and
previous the same element will be returned repeatedly).
void Add (e e);
inserts the specified element into the list (optional action).
The listiterator is compared to the normal iterator,Listiterator adds the function of the forward iteration, and Listiterator can also use the Add method to
Add elements to the list collection (iterator can only delete elements).
Reprint Please specify source:http://blog.csdn.net/hai_qing_xu_kong/article/details/44025709 Emotional Control _
Java Learning Note 25