Home > DeveloperSection > Interviews > 11.Difference between Vector and ArrayList? What is the Vector class?

Posted on    April-16-2011 1:06 AM

 Java Java 
 1 Answer(s)
  1986  View(s)
Rate this:

Amit Singh

Total Post:565

Posted on    April-16-2011 12:00 AM

Vector & ArrayList both classes are implemented using dynamically resizable arrays, providing fast random access and fast traversal. ArrayList and Vector class both implement the List interface. Both the classes are member of Java collection framework, therefore from an API perspective, these two classes are very similar. However, there are still some major differences between the two. Below are some key differences
  • Vector is a legacy class which has been retrofitted to implement the List interface since Java 2 platform v1.2
  • Vector is synchronized whereas ArrayList is not. Even though Vector class is synchronized, still when you want programs to run in multithreading environment using ArrayList with Collections.synchronizedList() is recommended over Vector.
  • ArrayList has no default size while vector has a default size of 10.
  • The Enumerations returned by Vector's elements method are not fail-fast. Whereas ArraayList does not have any method returning Enumerations.

Don't want to miss updates? Please click the below button!

Follow MindStick