Functions of vectors:
1. can store any object
2. Cannot store basic types of data, such as 39, unless the data is wrapped in a parcel class
3. Its capacity can be automatically expanded according to demand
4. Increase the efficiency of the element method if the capacity is not expanded
Way:
Vector myvector=new vector ()///initial capacity of 10
Vector myvector=new vector (int cap)//initial capacity is cap
Vector myvector=new Vector (Collection col)//using the elements of the collection Col to initialize, and if you col an array, you need to convert it to a list object first
Example: Vector myvector=new vector (arrays.aslist (col));
void Add (Object obj)//Adds the given parameter object to the last of the vector's original element
Boolean AddAll (colletion col)//Adds all elements in the collection class object to the recipient object of this method, returns true if the recipient's result is changed
int size ()//Returns the number of elements
Boolean isempty ()//Determine whether the vector is empty
Object get (int pos)//return element at specified position
void set (int pos,object obj)//Replace an object in the vector with the position pos
Boolean remove (Object obj)//deletes the first obj object found, returns true. False if not found
Objectremove (int pos)//remove element from a given position and return the object being removed
Boolean RemoveAll (Collection col)//Delete all objects in the vector that appear in Col, return true if the recipient's result is changed
void clear ()//delete all elements of a vector
Boolean contain (Object obj)//Determine whether the vector contains obj
Boolean containall (Collection col)//Determine whether the vector contains all the elements in Col
int indexOf (Object obj)//returns the position of obj at the first occurrence of the vector and returns 1 if it is not found
Enumeration elements ()//Returns the enumeration object for all elements in the vector, noting that this method cannot be used for ArrayList
Iterator iterator ()//Return iterator object for all elements in vector
Special Note: Object get (int pos)//Read position is the element of POS, because it returns an object, so it needs to be plastic (explicit conversion)
Cases:
for (int i=0;i<v.size (); i++)
Custmer c= (Custmer) v.get (i); Every object read from V needs to be explicitly converted before it can be used correctly.