Deep Learning of Vector sets and deep learning of vector
First, Vector is the list implementation provided by JDK. Like ArrayList, Vector is also implemented based on arrays.
Create an array of 10, assign values to the elementData object, and set capacityIncrement to 0.
The add method in the Vector adds the synchronized keyword, so this method is thread-safe. In addition, it is basically the same as the ArrayList. The difference is that when the array size is insufficient, the amplification policy is different (if capacityIncrement is greater than 0, the value of capacityIncrement is extended to the current size with the value of capacityIncrement. If capacityIncrement is less than 0, the Object array size is exaggerated to twice the existing size)
Except that the removeElement method called has the synchronized keyword, it is exactly the same as the arrayList.
The method has the syhchronized keyword, And the implementation is the same as that of ArrayList.
Identical to ArrayList
The only difference from ArrayList is that the indexOf method has the synchronized keyword.
Vector is a thread-safe ArrayList Based on synchronized. The amplification method is slightly different from that of ArrayList. You can pass in capacityIncrement to control capacity expansion.