This problem first looks at the common denominator:
- The positions of the elements stored in these two collections are ordered, equivalent to a dynamic array that can be taken out of an element by position
- Implements the list interface
- The elements in the collection allow duplicates
- You can set the initial space size
Difference:
- Thread Safety
- Data growth
If there is only one thread routines access to the collection, it is best to use ArrayList, because it does not consider thread safety, it is more efficient if there are multiple lines routines access to the collection, it is better to use vectors, because we do not need to consider and write thread-safe code (note: for vector &arraylist, Hashtable&hashmap, to remember the thread safety issues, remember that vectors and Hashtable are old, Java is provided in the birth, they are thread-safe, ArrayList and HashMap are provided at JAVA2, and they are thread insecure. So, we talk about the old first class. The vector grows by default to twice times the original, and can also be set to increase the size of the space ArrayList is 1.5 times times the original, and does not provide a way to set the growth space: vector, thread-safe, carefree, extravagant, free. ArrayList, efficiency first, careful, step-by-step, and all-out.
ArrayList VS Vector