Java – Vector class

Java – Vector class 2017-08-09T12:19:42+00:00

Java Vector class :

  • Java Vector class is one of the most important in all of the Java class libraries. We cannot expand the size of a static array.
  • We may think of a vector as a dynamic array that automatically expands as more elements are added to it.
  •  All vectors are created with some initial capacity.
  • When space is needed to accommodate more elements, the capacity is automatically increased.
  • That is why vectors are commonly used in java programming.

This class provides the following constructors:

Vector()

Vector(int n)

Vector(int n, int delta)

  • The first form creates a vector with an initial capacity of ten elements.
  •  The second form creates a vector with an initial capacity of n elements.
  • The third form creates a vector with an initial capacity of n elements that increases by delta elements each time it needs to expand.

EX :


 


Output :
Bhagirath
Hi
2500
23.25

Prev Next