The Vector class implements a growable array of objects. Vectors fall in legacy classes, but now it is fully compatible with collections.
Vector implements a dynamic array which means it can grow or shrink as required. Like an array, it contains components that can be accessed using an integer index
code
import java.io.*;
import java.util.*;
class GFG {
public static void main(String[] args)
{
int n = 5;
Vector<Integer> v = new Vector<Integer>(n);
for (int i = 1; i <= n; i++)
v.add(i);
System.out.println(v);
v.remove(3);
System.out.println(v);
for (int i = 0; i < v.size(); i++
System.out.print(v.get(i) + " ");
}
}
Output
[1, 2, 3, 4, 5]
[1, 2, 3, 5]
1 2 3 5