Vector
A Vector implements a dynamic array. It is simmilar to ArrayList, but along with two differences: a Vector is synchronized, and it holds various legacy methods which are not part of the collections framework. Along With the release of java2, vector was reengineered to extend AbstractList and implement the list interface, so it now is fully compatible with the collections.
Given below are the vector constructors.
Vector()
Vector(int size)
Vector(int size, int incr)
Vector(Collection c)
The first form creates a default vector that has an initial size of 10. A second form creates a vector whose initial capacity is specified through size. The third form creates a vector whose initial capacity is specifies the number of elements to allocate every time in which a vector is resized upward. The fourth form creates a vector which holds the elements of collection c. This constructor was added through Java2.
Vector declares these protected data members:
int capacityIncrement;
int elementCount;
Object elementData [ ];
An increment value is stored in capacity increment. A number of elements presently in the vector is stored in elementCount. The array which contains the vector is stored in elementData.
Further to the collection methods defined through List, Vector defines various legacy methods, that are displays in Table .
Since Vector implements List so you can use a vector like you use an ArrayList instance. You could also manipulate one using its legacy methods. For instance, after you instantiated a Vector you could add an element to vector by calling addElement ( ). To get the element at a specific location, call elementsAt ( ). For obtain the first element in the vector, call firstElement ( ). For retrieve the last element, call lastElement ( ). You can obtain the index of an element through using indesOf( ) and lastInsdexOf ( ). For remove an element, call removeElement ( ) or removeElement( ).