What is the difference between ArrayList and Vector?

Asked 2 years ago, Updated 2 years ago, 91 views

What is the difference between the two data structures of ArrayList and Vector? Where should I use each of them?

vector arraylist java

2022-09-22 08:07

1 Answers

First of all, the basic movements are both similar. The difference between the two is that Vector is a class that was created at 1.0 and has been maintained until now, and then List appears.

The difference between List objects that appear after Vector is in the "synchronize" processing. Because Vector is "unconditional synchronization", single thread processing is inferior to ArrayList. The main purpose of using Vector from Java 1.2 is compatibility with 1.0. I'm almost out of use. The reason is that collection, synchronized collection, synchronized list, and map are better performance-wise than Vector when synchronized processing is required.

ArrayList is an implementation object of Collection that appeared in 1.2. Additional deletion of data is the same as Vector The internal automatic synchronization feature has been deleted.

Therefore, if you want to use either of the two, use ArrayList, and if you need to synchronize with multiple threads, We recommend that you use the other data structure described above rather than Vector.


2022-09-22 08:07

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.