This way, vector v has an internal array of size 10.But what is the incremental size of this Vector.
if I declare a Vector this way and later on during run time I have to add 15 elements to this vector, will this vector add those 15 elements or it will give me some exception?
What is the difference between declaring vector with :
Vector v = new Vector()
and
Vector v = new Vector(10)
But I think that if we declare Vector as:
Vector v = new Vector(20);
then the default increment value is 20. ie if Vector has to increase its capacity it will increase it by 20. ie doubling the capacity vector.
from javadocs
----------------
public Vector(int initialCapacity)
Constructs an empty vector with the specified initial capacity and with its capacity increment equal to zero.
from javadocs
--------------
public Vector(int initialCapacity,int capacityIncrement)
Constructs an empty vector with the specified initial capacity and capacity increment.
But I think that if we declare Vector as:
Vector v = new Vector(20);
then the default increment value is 20. ie if Vector has to increase its capacity it will increase it by 20. ie doubling the capacity vector.
from javadocs
----------------
public Vector(int initialCapacity)
Constructs an empty vector with the specified initial capacity and with its capacity increment equal to zero.
from javadocs
--------------
public Vector(int initialCapacity,int capacityIncrement)
Constructs an empty vector with the specified initial capacity and capacity increment.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |