Differences between ArrayList and ArrayList in Java, and between ArrayList and Vector.

Source: Internet
Author: User

Differences between ArrayList and ArrayList in Java, and between ArrayList and Vector.

Everyone knowsDifferences between ArrayList and rule list:

1. ArrayList is a dynamic array-based data structure. The ArrayList is based on the linked list data structure.

2. for Random Access to get and set, ArrayList thinks it is better than the sorted list because the sorted list needs to move the pointer.

3. For add and remove operations, LinedList is dominant because ArrayList needs to move data.

ArrayList and referlist are two collection classes used to store a series of object references ). For example, we can use ArrayList to store a series of strings or integers.

So what is the performance difference between ArrayList and javaslist? When should I use ArrayList? When should I use the rule list?

 

It can be said that when the operation is to add data after a column of data rather than in the front or middle, and needs to randomly access the elements, using ArrayList will provide better performance;

When you add or delete data in front or middle of a column of data and access the elements in the column in sequence, you should use the sort list.

 

Differences between ArrayList and Vector

Like ArrayList, Vector is implemented through arrays. The difference is that it supports thread synchronization, that is, only one thread can write a Vector at a time point,

Avoid inconsistency caused by simultaneous write of multiple threads, but it is costly to implement synchronization. Therefore, it is slower to access ArrayList than to access ArrayList.

 

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.