What are the differences between vector, arraylist, and arraylist?
Sort list class
The listlist interface allows
null
Element.
In addition, the values list provides additional get, remove, and insert methods at the beginning or end of the values list.
The consumer list is not synchronized (not thread-safe ).
Implement thread security: List list =
Collections.synchronizedList(
new
LinkedList(...));
Fast addition, deletion, and slow query.
ArrayList class
ArrayList implements an array of variable sizes. It allows
null
。
ArrayList is not synchronized.
Slow addition, deletion, and fast query.
Vector
Vector thread security. Low Efficiency
The differences between ArrayList and Vector are as follows:
1. When the memory of ArrayList is insufficient, the default number is 50% + 1, and the Vector is doubled by default.
2. Vector provides the indexOf (obj, start) interface, which is not available in ArrayList.
3. Vector is thread-safe, but Vector is not used in most cases, because thread security requires greater system overhead.