Three constructors of Vector:
Public Vector (int initialCapacity, int capacityIncrement ){
Super ();
If (initialCapacity <0)
Throw new IllegalArgumentException ("Illegal Capacity:" +
InitialCapacity );
This. elementData = new Object [initialCapacity];
This. capacityIncrement = capacityIncrement;
}
Public Vector (int initialCapacity ){
This (initialCapacity, 0 );
}
Public Vector (){
This (10 );
}
Vector Method:
Insert function:
(1) public final synchronized void adddElement (Object obj)
Insert obj to the end of the vector. Obj can be any type of object. You can insert objects of different classes to the same vector object. But the inserted value should be an object rather than a value. Therefore, when inserting a value, you must convert the array to the corresponding object.
For example, to insert an integer of 1, do not directly call v1.addElement (1). the correct method is: