Difference Between ArrayList and Vector in Java

Connect with

Difference Between ArrayList and Vector in JavaWhat is basic Difference Between ArrayList and Vector in Java? Every java developer should know the answer of this questions.

There is nothing wrong or right to implementation, so it completely depends on what you need and what you want to achieve. The interviewer asked this type of question to check the basics fundamental things of the candidate and slowly they increase the level of question and time on the candidate.

Difference between ArrayList and Vector in Java

In this interview series of differences between, I tried to cover basics Difference Between ArrayList and Vector in Java. Vector vs ArrayList is one of the important questions for cracking the entry level of developer to check whether you know the basic building block of Java or not.

  1. Synchronization: Vector is syncronized while ArrayList is not synchronized List. Vector is synchronized means it’s method are synchronized , while ArrayList is not synchronized it means its method not.
  2. Threadsafe: Vector is thread safe while arrayList is not thread safe
  3. Growth: Vector has double its size while ArrayList is its half of its size. Vector grows to double in size of its array when exceeds its size while adding , while ArrayList grows half i.e. 50% of its size
  4. Version: Vector is present since JDK 1.0 version while ArrayList added in JDK 1.2 version. vector class refactored tolist in 1.2 of jdk

Differences between some java classes

You can visit other differences between two java classes:

Write your suggestions to improve this post. Happy Learning for ArrayList vs vector in Java.


Connect with

Leave a Comment

Your email address will not be published. Required fields are marked *