Vector class provides 3 constructors which can be used according to the needs. Following example will help you understand how the size of Vector grows.
// constructor without any argument -- default size is 10
Vector v1 = new Vector();
// constructor with 1 argument -- size doubles as entries increases
Vector v2 = new Vector(4);
// constructor with 2 argument -- size increases according to the 2 int argument
Vector v3 = new Vector(2,2);
System.out.println("Capacity of v1 " + v1.capacity());
System.out.println("Capacity of v2 " + v2.capacity());
System.out.println("Capacity of v3 " + v3.capacity());
v2.addElement("Australia");
v2.addElement("Brazil");
v2.addElement("Germany");
v2.addElement("France");
v2.addElement("Itlay");;
System.out.println("Updated capacity of v2 " + v2.capacity());
v3.addElement("Australia");
v3.addElement("Brazil");
v3.addElement("Germany");
System.out.println("Updated capacity of v3 " + v3.capacity());
Output:
Capacity of v1 10
Capacity of v2 4
Capacity of v3 2
Updated capacity of v2 8
Updated capacity of v3 4