Vector is a class which extends AbstractList and implements List interface.
- Vector is a Legacy collections class. Which is introduced in Java 1.0.
- Vector is synchronized, so it can be used in multi threading.
- Vector implements Random access interface so we can access the elements from the vector randomly.
- Initial capacity of vector is “10” . When it reaches to max then capacity will be increased to double.
- All vector specific methods are synchronized.
Constructors:
- Vector(): Creates empty Vector with initial capacity “10”.
- Vector(int capacity): Creates empty vector with specified capacity.
- Vector(int capacity, int incrementalCapacity): Creates empty vector with specified capacity and when it reaches to max capacity then add the incrementalCapacity.newCapacity = oldCapacity + incrementalCapacity ;
- Vector(Collection c): It creates the Vector which will contain all the elements of the specified Collection.