|
![]() |
Constructor Summary
Vector()
Constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero.
Vector(Collection c)
Constructs a vector containing the elements of the specified collection, in the order they are returned by the collection's iterator.
Vector(int initialCapacity)
Constructs an empty vector with the specified initial capacity and with its capacity increment equal to zero.
Vector(int initialCapacity, int capacityIncrement)
Constructs an empty vector with the specified initial capacity and capacity increment.
Originally posted by thomas davis:
Case 1)Vector objVector = new Vector(5,10);
If I have a vector intitialized as given above,and I add 6 th element to it ,How the vector will react to it?How does the internal array get incremented?
What is the significance of 5 and 10?
, and 10 isthe initial capacity of the vector.
the amount by which the capacity is increased when the vector overflows.
Does it give a crappy performance?
What do I have to do it for better performance?
SJCP 1.2
QUESTION:
Vector objVector = new Vector();
by adding the one element int the vector, what would be the Vectors size?, What would be the internal data array's size ?, add a 2nd element what would be the internal array size?
Vector
public Vector()Constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero.
capacityIncrement
protected int capacityIncrementThe amount by which the capacity of the vector is automatically incremented when its size becomes greater than its capacity. If the capacity increment is less than or equal to zero, the capacity of the vector is doubled each time it needs to grow.
What are you doing? You are supposed to be reading this tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
|