ArrayList and LinkedList are two typical implementations of linear tables: array-based linear tables and chain-based linear tables.
The queue represents queues, and deque represents a double-ended queue.
In general, because the array holds all the array elements in a contiguous memory area, the array has the best performance at random access;
The set of the internal list as the bottom implementation of the implementation of the INSERT, delete operations have good performance.
Overall, ArrayList performance is better than LinkedList performance, so ArrayList should be considered most of the time.
Here are some suggestions for using the list collection:
- If you need to traverse the list collection element, for ArrayList, vector collections, you should use the random access method (get) to traverse the performance better, and for the LinkedList collection, you should use Iterators (Iterator) to iterate through the collection elements.
- If you want to change a list collection that contains large amounts of data frequently, you should use the LinkedList collection. Because using ArrayList, vector collections may require frequent reallocation of memory.
- If you have multiple threads that need to access the elements in the list collection at the same time, consider wrapping the collection as a thread-safe collection using collections.
Java Collection Class Learning notes (various linear table performance analysis)