Vector Class in Java

Last Updated : 18 Nov, 2025

In Java, a Vector is a dynamic array that can grow or shrink in size as elements are added or removed. It is part of the java.util package and extends the AbstractList class.

  • Maintains insertion order and allows duplicate and null values.
  • Dynamically grows its size when capacity is exceeded.
  • Implements List, RandomAccess, Cloneable, and Serializable interfaces.
  • Vector is a Legacy class that was introduced in early versions of Java.
  • Thread-safe: All methods are synchronized for safe multi-threaded access.
  • ArrayList is preferred over vector in general when in-built thread synchronization is not required..
Java
import java.util.Vector;

public class GFG{
    
    public static void main(String[] args){
        
        Vector<String> v = new Vector<>();
        v.add("A");
        v.add("B");
        v.add("C");
        System.out.println(v);
    }
}

Output
[A, B, C]

Hierarchy of Vector

It implements the List interface, which is a sub-interface of the Collection interface.