first of all, both classes implement the list interface, and the list interface has three implementation classes, namely ArrayList, Vector, and LinkedList. The list is used to hold multiple elements, to maintain the order of elements, and to allow the repetition of elements.
The related differences between the 3 specific implementation classes are as follows:
1.ArrayList is the most commonly used list implementation class, implemented internally by an array, which allows for fast random access to elements. The disadvantage of an array is that there can be no interval between each element, and when the array size does not meet the need to increase storage capacity, it is necessary to copy the data of the array into the new storage space. When inserting or deleting elements from the middle of a ArrayList, it is necessary to copy, move, and cost the array. Therefore, it is suitable for random lookups and traversal, and is not suitable for insertions and deletions.
2.Vector, like ArrayList, is also implemented through arrays, except that it supports thread synchronization, where only one thread can write vectors at a time, avoiding inconsistencies caused by simultaneous writing of multiple threads, but achieving synchronization requires a high cost, so Accessing it is slower than accessing ArrayList.
3.LinkedList is used to store data in a linked list structure, which is very suitable for the dynamic insertion and deletion of data, and the random access and traversal speed is relatively slow. In addition, he provides methods that are not defined in the list interface, specifically for manipulating the header and footer elements, and can be used as stacks, queues, and bidirectional queues.
The differences between ArrayList and vectors are as follows:
1.ArrayList is the default extension of 50% + 1 when memory is insufficient, vector is 1 time times the default expansion.
The 2.Vector provides the indexof (obj, start) interface, ArrayList not.
3.Vector is thread-safe, but in most cases does not use vectors, because thread safety requires greater overhead.
A detailed explanation of the difference between vector and ArrayList in Java