![]() |
VOOZH | about |
In Java, Vector Class allows to creation of dynamic arrays that can grow or shrink as per the need. If we know the approximate size of elements, we will store this in the vector. Then we optimize memory usage, and we can initialize it with the specific initial capacity.
In this article, we will learn how to initialize a Vector with a specific initial capacity in Java.
Input: int initialCapacity = 10;Vector<String> string
Vector = new Vector<>(initialCapacity);Output: A Vector named stringVector is created with the initial capacity of 10.
Vector<E> vector = new Vector<>(initialCapacity);Below is the implementation to Initialize a Vector with Initial Capacity:
The Vector elements: [Java, is, powerful.]
In the above program,