Java Vector removeElement() Method
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.
Following is the declaration of removeElement() method:
The removeElement() method returns true if the argument was a component of the vector, otherwise returns false.
Java 1.2 and above
Example 1Test it Now
Vector element before removal: [1, 2, 3, 4, 5, 6] Vector element after removal: [1, 2, 3, 4, 6]
Example 2Test it Now
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]