Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Java Vector Constuctors

Java Vector Constructors

1) Vector()
Creates a new empty vector with size 10 and capacityIncrement 0.

Example
Vector v = new Vector();

Creates a new Vector object with size 10.

2) Vector (int initialCapacity)
Creates a new empty vector with the specified initial capacity and with capacityIncrement equal to 0.

Example
Vector v = new Vector(100);

Creates a new Vector with initialCapacity equals to 100 and capacityIncrement equals to 0.

3) Vector (Collection c)
Creates a new vector containing elements of the specified collection in the order returned by the Collection’s Iterator.

Example
Vector v = new Vector(myCollection);

Where myCollection is the Object of type Collection.

4) Vector (int initialCapacity, int capacityIncrement)
Creates a new empty vector with the specified initial capacity and with specified capacityIncrement.

Example
Vector v = new Vector(100,20);

Creates a new Vector with initialCapacity equals to 100 and capacityIncrement equals to 20.


<< Java Vector Tutorial
     Java Vector Search Elements >>
No votes yet
Share this

Post new comment