In Java, while you can give the size of arrays at run time, you cannot dynamically change the size of an array during the computation. The vector class provides a data structure with this property - the restriction is that all of the elements must be of type Object.
|
A vector is created with an "initial capacity" and a "capacity increment". It always starts with 0 elements. As you add elements, if the initial capacity is exceeded, then more memory is automatically allocated in the size of the capacity increment. The default is an initial capacity of 10 and an increment which doubles each time.
|