Vector

Vector is a class which extends AbstractList and implements List interface.

  1. Vector is a Legacy collections class. Which is introduced in Java 1.0.
  2. Vector is synchronized, so it can be used in multi threading.
  3. Vector implements Random access interface so we can access the elements from the vector randomly.
  4. Initial capacity of vector is “10” . When it reaches to max then capacity will be increased to double.
  5. All vector specific methods are synchronized.

Constructors:

  1. Vector(): Creates empty Vector with initial capacity “10”.
  2. Vector(int capacity): Creates empty vector with specified capacity.
  3. 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 ;
  4. Vector(Collection c): It creates the Vector which will contain all the elements of the specified Collection.
Advertisements