Vector class Methods in Java Part -II

java.util.Vector

The Vector class implements a growable array of objects. Like an array, it contains components that can be accessed using an integer index. However, the size of a Vector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created.


Some methods of Vector class.


hashCode(): This method returns the hash code value for this Vector.


indexOf(Object): This method returns the index of the first occurrence of the specified element in this vector, or -1 if this vector does not contain the element.


indexOf(Object, int): This method returns the index of the first occurrence of the specified element in this vector, searching forwards from the index or returns -1 if the element is not found.


insertElementAt(K, int): This method inserts the specified object as a component in this vector at the specified index.


isEmpty(): This method tests if this vector has no components.


iterator(): This method returns an iterator over the elements in this list in proper sequence.



lastElement(): This method returns the last component of the vector.


lastIndexOf(Object): This method returns the index of the last occurrence of the specified element in this vector, or -1 if this vector does not contain the element.


lastIndexOf(Object, int): This method returns the index of the last occurrence of the specified element in this vector, searching backward from the index, or returns -1 if the element is not found.


listIterator(): This method returns a list iterator over the elements in this list.


listIterator(int): This method returns a list iterator over the elements in this list starting at the specified position in the list.


remove(int): This method removes the element at the specified position in this Vector. Shifts any subsequent elements to the left (subtracts one from their indices).


remove(Object): This method removes the first occurrence of the specified element in this Vector. If the Vector does not contain the element, it is unchanged.


removeAll(Collection): This method removes from this Vector all of its elements that are contained in the specified Collection.


removeAllElements(): This method removes all components from this vector and sets its size to zero.


removeElement(Object): This method removes the first (lowest-indexed) occurrence of the argument from this vector.


removeElementAt(int): This method deletes the component at the specified index.


removeIf(Predicate): This method removes all of the elements of this collection that satisfy the given predicate.


Some more methods of Vector class Part -I


Some more methods of Vector class Part -III


No comments:

Post a Comment