1. ArrayList
Array-based implementation without capacity restrictions.
You may need to expand the number of inserted elements. When deleting an element, the array capacity is not reduced.
To reduce the array capacity, you can call trimToSize ()
When searching for elements, You need to traverse the array and search for non-null elements in equals mode.
Non-thread security.
2. shortlist
Based on the two-way linked list mechanism.
Fast element insertion and movement.
Non-thread security.
3. Vector
Object array-based implementation.
Thread-safe ArrayList Based on synchronized.
The Capacity Expansion Mechanism for inserting elements is slightly different from that for ArrayList:
If capcacityIncrement> 0, the size of the Object array is expanded to the existing size plus capcacityIncrement;
If capcacityIncrement <0, the size of the Object array is doubled to the existing size;
4. Stack
Implemented based on Vector and supports LIFO.
5. HashSet
Implemented based on HashMap without capacity restrictions.
Duplicate elements are not allowed.
Non-thread security.
6. TreeSet
It is implemented based on TreeMap and supports sorting.
Non-thread security.
7. HashMap
The Entry object consisting of key and value is stored in arrays without capacity restrictions.
Search for the location where the Entry object is stored in the array based on key hash, and use the Linked List Method to Solve the hash conflict.
When an element is inserted, the array capacity may be increased. When the array capacity is increased, the hash is recalculated and the object is copied to the new array.
Non-thread security.
8. TreeMap
Implemented based on the red/black tree with no capacity limit.
Non-thread security.
-----------------------------------
Applicable scenarios:
Set or Map is a better choice for applications with frequent search and deletion and a large number of elements;
ArrayList is applicable to reading elements by position;
The sequence list is applicable to scenarios where you want to start or end operations or insert a specified position;
Vector is applicable to the scenario of ArrayList for thread security;
Stack is applicable to LIFO scenarios with thread security;
HashSet is suitable for storing non-repeating elements that do not require sorting;
TreeSet is suitable for storing non-repeating elements to be sorted;
HashMap is applicable to most key-value access scenarios;
TreeMap is applicable to key-value scenarios that require sorting and storage.