A vector is a data structure in Java. Like the name suggests, a vector is a kind of sequence of elements. It uses a dynamic array that grows and shrinks as it is accessed. It has a size() method to get the current size of the vector and a capacity() method to get the capacity of the vector. These two methods return the values greater than zero. The capacity of the vector is the number of elements that can be stored inside the vector without having to allocate a new array. The size of the vector is the number of elements currently stored inside the vector.