publicvoidset(int index, E element) //用指定元素替换此向量中指定位置的元素。 publicvoidsetElementAt(E element,int index) //将此向量的指定索引处的组件设置为指定对象。
删除元素
1 2 3 4 5 6 7 8 9 10 11 12
publicvoidclear() //Removes all of the elements from this Vector. publicvoidremoveAllElement() //Removes all components from this vector and sets its size to zero. publicvoidremove(int index ) //Removes the element at the specified position in this Vector. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the Vector. publicvoidremoveElementAt(int index) //Deletes the component at the specified index. publicbooleanremove(object obj) //Removes the first occurrence of the specified element in this Vector If the Vector does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists). publicbooleanremoveElement(object obj) //Removes the first (lowest-indexed) occurrence of the argument from this vector. If the object is found in this vector, each component in the vector with an index greater or equal to the object's index is shifted downward to have an index one smaller than the value it had previously.
publicbooleancontains(object obj) //Returns true if this vector contains the specified element. publicbooleanequals(object obj) //Compares the specified Object with this Vector for equality. publicintindexof(object obj) //Returns the index of the first occurrence of the specified element in this vector, or -1 if this vector does not contain the element. publicintindexof(object obj,int index) //Returns the index of the first occurrence of the specified element in this vector, searching forwards from index, or returns -1 if the element is not found. publicintlastIndexof(object obj) //Returns the index of the last occurrence of the specified element in this vector, or -1 if this vector does not contain the element. publicintlastIndexof(object obj,int index) //Returns the index of the last occurrence of the specified element in this vector, searching backwards from index, or returns -1 if the element is not found. publicintcapacity() //Returns the current capacity of this vector. publicintsize() //Returns the number of components in this vector. publicbooleanisEmpty() //Tests if this vector has no components. publicvoidsetSize(int newSize) //Sets the size of this vector.