Vector Example in Java

Vector can be used to implement dynamic Array. It can accommodate any number and any type of objects. It is used to store various objects into a single unit.

Program to access the Vector class in Java

Vectors are another form of Arrays in Java. The difference between array and vector is that Vector is a generic dynamic array that can hold any number of objects. The vector class is defined in the special package and that is java.util package.

Vector in Java


Vector class can be used to create a generic dynamic array known as Vector that can hold objects of any type and any number. The object do not have to be homogeneous(same type).In Vector we use java.util package.

Array can be easily implemented as vector. Vector are created like Array as:

Without Size……….Vector v=new Vector();

WithSize……………..Vector v1=new Vector(3);