1. ArrayList
Implementation based on array, no capacity constraints.
When you perform an INSERT element, you may have to expand it, and deleting an element does not reduce the size of the array.
If you want to reduce the size of the array appropriately, you can call TrimToSize ()
When looking for an element, you want to enumerate the groups and look for a non-null element in the same way as equals.
Not thread safe.
2. LinkedList
Based on the bidirectional linked list mechanism implementation.
Elements are inserted and moved faster.
Not thread safe.
3. Vector
Based on the method of an object array.
Thread-safe ArrayList based on synchronized implementations.
The mechanism for capacity expansion is slightly different from the ArrayList when inserting elements:
If capcacityincrement > 0, the size of the object array expands to the existing size plus the capcacityincrement;
If Capcacityincrement < 0, the size of the object array expands to twice times the existing size;
4. Stack
Based on Vector implementations, supports LIFO.
5. HashSet
Based on HASHMAP implementation, no capacity limit.
Element duplication is not allowed.
Not thread safe.
6. TreeSet
Based on TREEMAP implementations, supports sorting.
Not thread safe.
7. HashMap
The entry object consisting of key and value is stored in array mode, without capacity restriction.
Based on the key hash to find the location of the entry object to the array, for the hash conflict using a linked list to solve.
The size of the array may be enlarged when the element is inserted, the hash is recalculated when the capacity is expanded, and the object is copied into the new array.
Not thread safe.
8. TreeMap
Based on the red-black tree implementation, no capacity constraints.
Not thread safe.
-----------------------------------
Applicable scenario:
A set or map is a better choice for applications that find and delete more frequently and have a larger number of elements.
ArrayList is suitable for scenes that read elements by location;
LinkedList is suitable for scenes that are to be operated or inserted at a specified position;
Vectors apply to ArrayList scenarios that are thread-safe;
Stack applies to thread-safe LIFO scenarios;
HashSet is suitable for storing non repetitive elements that are not required for sorting;
TreeSet applies to the storage of the distinct elements to be sorted;
HashMap is suitable for most key-value access scenes;
The
TreeMap is suitable for key-value scenarios that need to be sorted and stored.