
[]
4.11 Object Wrappers
4 7
4.10 Vectors
Recall from Chapter 2 that once we create an array we cannot change its size. Vectors, on
the other hand, can grow and shrink at runtime as required. A Vector is an object of the
java.util.Vector class. A Vector object is created using the new keyword, for example,
Vector vlist = new Vector();
This creates a Vector object, vlist, with default capacity of ten elements. As soon as 10 ele-
ments have been added, the capacity, by default, will be doubled to 20 elements in total. It is
possible to specify other capacities and increment factors. To add ...