Features of the list collection:
Sequential (the elements stored and removed are identical), repeatable.
For example
Unique features of the list collection:
* A: Add features
* void Add (int index,object element): Adding elements at the specified location
* B: Get Features
* Object get (int index): Gets the element at the specified position
* C: List iterator
* Listiterator listiterator (): List collection-specific iterator
* D: Delete function
* Object Remove (int index): Deletes elements based on index, returns deleted elements
* E: Modify function
* Object Set (int index,object element): Modifies the element according to the index, returning the decorated element
Subclasses of the list collection
List: Elements are ordered and elements can be duplicated. Because the collection system has an index.
ArrayList: The underlying data structure uses an array structure. Features: Fast query speed. But additions and deletions are slightly slower. Thread is out of sync.
LinkedList: The underlying uses a linked list data structure. Features: Deletion speed quickly, query slightly slow.
Vector: The bottom layer is the array data structure. Thread synchronization. Replaced by the ArrayList.
LinkedList
LinkedList: The underlying uses a linked list data structure. Features: Deletion speed quickly, query slightly slow.
Unique methods:
1, increase
AddFirst ();
AddLast ();
2. Get
Gets the element, but does not delete the element. If there are no elements in the collection, Nosuchelementexception appears
GetFirst ();
GetLast ();
3. By deleting
Gets the element and deletes the element. If there are no elements in the collection, Nosuchelementexception appears
Removefirst ();
Removelast ();
After the JDK1.6, there was an alternative approach.
1, increase
Offfirst ();
Offlast ();
2. Get
Gets the element, but does not delete it. If there are no elements in the collection, NULL is returned.
Peekfirst ();
Peeklast ();
3. By deleting
Gets the element and deletes the element. If there are no elements in the collection, NULL is returned.
Pollfirst ();
Polllast ();
Dark Horse Programmer ———— List Collection of Java Collections (ii)