Difference between Vector and ArrayList

 

1. Vector & ArrayList 
1) The methods of Vector are all synchronized and thread-safe, while the methods of ArrayList are not. Because the synchronization of threads will inevitably affect the performance, the performance of ArrayList is better than that of Vector. Okay. 
2) When the elements in Vector or ArrayList exceed its initial size, Vector will double its capacity, while ArrayList will only increase its size by 50%, so ArrayList will help save memory space.

2. Hashtable & HashMap 
Hashtable and HashMap are similar in performance to Vector and ArrayList. For example, the method of Hashtable is synchronous, while that of HashMap is not.


3. ArrayList & LinkedList

The internal implementation of ArrayList is based on the internal array Object[], so conceptually, it is more like an array, but the internal implementation of LinkedList is based on a set of connected records, so it is more like a linked list structure, so they are in performance. There is a big difference: 
       from the above analysis, when inserting data in the front or middle of the ArrayList, you must move all the data behind it accordingly, which will inevitably take a lot of time. Therefore, when your operation It is to add data after a column of data rather than in the front or middle, and when you need to access the elements randomly, using ArrayList will provide better performance; when accessing an element in the linked list, you must start from one end of the linked list. Start to search element by element along the connection direction until you find the desired element, so when your operation is to add or delete data before or in the middle of a column of data, and access the elements in order, you should Use LinkedList too. 

 

Source: http://www.cnblogs.com/plmnko/archive/2010/10/10/1847362.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326174962&siteId=291194637