Differences between vector and arraylist in Java

Source: Internet
Author: User
Http://www.jdon.com/jivejdon/thread/11661.html

1. vector is thread-synchronous, so it is thread-safe, while arraylist is asynchronous and insecure. If thread security is not taken into account, arraylist is generally used for high efficiency.
2. If the number of elements in the set is greater than the length of the current set array, the growth rate of vector is 100% of the current array length, and that of arraylist is 50% of the current array length. if you use a large amount of data in a collection, using vector has some advantages.
3. If you look for data at a specified position, the time used by the vector and arraylist is the same, both of which are 0 (1). In this case, you can use both vector and arraylist. If it takes 0 (n-I) n to move the data at a specified position as the total length, you should consider using linklist, because it takes 0 (1) to move data at a specified location, and the time spent querying data at a specified location is 0 (I ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.