One, List:
1, the Special Common method: (there is a common feature is that all can operate the angle mark)
(1), add
void Add (int Index, E Element): Inserts an element at the specified position in the list
void AddAll (int index, COLLECTION<?) Extends e> E): Inserts all elements from the specified collection to the specified position in the list
(2), delete
E Remove (int Index): Deletes the element at the specified position and returns the element;
(3), modify
e Set (int index, E Element): Replaces the element at the specified position and returns the replaced element
(4), obtain
Int indexOf (Object O): Returns the index of the first occurrence of the specified element, or 1 if it is not included in the list;
E get (int Index): Returns the element at the specified position;
list<e> sublist (int fromIndex, int toindex): Returns a partial view (list) between the specified FromIndex (inclusive) and Toindex (not included) in the list;
2. The list cannot be manipulated when the list is iterated (add and revise)
You can use the subinterface listiterator of the iterator interface to complete the operations of the list during the iteration, and the List.listiterator () method returns the list iterator for this listing element, which can be reversed (hasprevious () Method and Previous ()), note that the Listiterator object should be manipulated when the list is manipulated, for example:
while (It.hasnext ()) {
Note that you cannot use List.add ("demo")!!!!!!
It.add ("demo");
}
3. Common Objects
|--Vector: The internal array data structure, is synchronous, 100% extended array, and delete queries are very slow.
|--ArrayList: The internal is the array data structure, is not synchronized, replaced the vector,50% extended array, the query several degrees faster.
|--linkedlist: Internal is a linked list data structure, is not synchronized, adding and deleting elements faster.
4, the Common object detailed
1. Vector
Enumeration
Enumeration en = V.elements ();
while (En.hasmoreelements ()) {
System.out.println (En.nextelement ());
}
Enum is the same as an iterator except that there is no remove method, it is recommended to use an iterator
2, LinkedList
Linkedlist.add ("Demo1");
Linkedlist.add ("Demo2");
Linkedlist.add ("Demo3");
System.out.print (LinkedList);
output [Demo3,demo2,demo1];
When iterating with LinkedList, the element is reversed output
LinkedList GetFirst () throws an exception nosuchelementexception when no data is fetched, but the 1.6 version of Peekfirst () returns Null (Pollfirst () corresponds to Removefirst ( ))
List of Java collection frameworks