What is the difference between Vector and ArrayList in Java?

Java 8Object Oriented ProgrammingProgramming


 An array list is created with an initial size. When this size is exceeded, the collection is automatically enlarged. When objects are removed, the array may be shrunk.


Vector implements a dynamic array. It is similar to ArrayList, but with two differences −

  1. Vector is synchronized.
  2. The vector contains many legacy methods that are not part of the collections framework.

Vector proves to be very useful if you don't know the size of the array in advance or you just need one that can change sizes over the lifetime of a program.

Updated on 30-Jul-2019 22:30:21