Java Vector removeElement() Method24 Mar 2025 | 2 min read The removeElement() method of Java Vector class is used to remove the first (lowest-indexed) occurrence of the argument from this vector. Removing an element decreases the vector size by one. SyntaxFollowing is the declaration of removeElement() method: Parameter
ReturnThe removeElement() method returns true if the argument was a component of the vector, otherwise returns false. ExceptionsNA Compatibility VersionJava 1.2 and above Example 1Output: Vector element before removal: [1, 2, 3, 4, 5, 6] Vector element after removal: [1, 2, 3, 4, 6] Example 2Output: The elements of a Vector before remove: [Rahul, Karan, Rahul, Rohan] Is the removal successful?? true The elements of the Vector after remove: [Karan, Rahul, Rohan] Next TopicJava Vector |
Java Method The hashCode() method of Java Vector class is used to get the hashcode value for the vector which is in use. Syntax: Following is the declaration of hashCode() method: public int hashCode() Parameter: This method does not accept any parameter. Returns: The hashCode() method returns the hash code value for...
2 min read
Java Method The indexOf() Java Vector class method is used to get the index of the first occurrence of the specified element in the vector. There are two different types of Java indexOf() method which can be differentiated depending on its parameter. These are: Java Vector...
3 min read
Java Method The iterator() method of Java Vector class is used to get an iterator over the elements in this list in proper sequence. Syntax Following is the declaration of an iterator() method: Public Iterator<E> iterator() Parameter This method does not accept any parameter. Return The iterator() method returns an iterator over...
2 min read
Java Method The insertElementAt() method of Java Vector class is used to insert the specified object as a component in this vector at the specified index. Each component in the vector with an index greater or equal to the given index is shifted upward. Now,...
3 min read
Java Method The equals() method of Java Vector class used to compare the specified object with this Vector for equality. It returns true if and only if the specified object is also a list, both lists have the same size and all corresponding pairs of...
2 min read
Java Method The firstElement() method of Java Vector class is used to get the first element ( at index 0 ) of the vector which is in use. Syntax: Following is the declaration of firstElement() method: public E firstElement() Parameter: This method does not accept any parameter. Returns: The firstElement() method returns...
2 min read
Java Method The ensureCapacity() method of Java Vector class is used to increase the capacity of the vector which is in use, if necessary. It ensures that the vector can hold at least the number of components specified by the minimum capacity argument. Syntax: Following is the...
2 min read
Java Method The toString() method of Java Vector class is used to get a string representation of the vector. It contains the string representation of each element. Syntax Following is the declaration of toString() method: public String toString() Parameter This method does not accept any parameter. Return The toString() method returns a...
2 min read
Java Method The removeAll() method of Java Vector class deletes all the elements from the vector that are present in the specified collection. Syntax Following is the declaration of removeAll() method: public boolean removeAll(Collection<?> c) Parameter Parameter Description Required/Optional c It is a collection of elements which will be removed from the vector. Required Return The removeAll()...
3 min read
Java Method The clear() method of Java Vector class is used to remove all of the elements from the vector which is in use. Syntax: Following is the declaration of clear() method: Public void clear() Parameter: This method does not accept any parameter. Returns: This method has return type void so, it...
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India