VOOZH about

URL: https://www.geeksforgeeks.org/java/vector-remove-method-in-java/

⇱ Vector remove() Method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Vector remove() Method in Java

Last Updated : 11 Jul, 2025
  • remove(int index)

    The java.util.vector.remove(int index) method is used to remove an element from a Vector from a specific position or index. Syntax:
    Vector.remove(int index)
    Parameters: This method accepts a mandatory parameter index is of integer data type and specifies the position of the element to be removed from the Vector. Return Value: This method returns the element that has just been removed from the vector. Below program illustrate the Java.util.Vector.remove(int index) method:
    Output:
    Vector: [Geeks, for, Geeks, 10, 20]
    Removed element: 20
    Final Vector: [Geeks, for, Geeks, 10]
    
  • remove(Object o)

    The java.util.vector.remove(Object o) method is used to remove any particular element from the Vector. Syntax:
    Vector.remove(Object o)
    Parameters: This method accepts a mandatory parameter o is of the object type of Vector and specifies the element to be removed from the Vector. Return Value: Returns True if the specified element is found and removed from the Vector, else False. Below program illustrate the Java.util.Vector.remove(Object O) method:
Output:
Vector: [Geeks, for, Geeks, 10, 20]
Geeks found and removed.
500 not found or removed.
Final Vector: [for, Geeks, 10, 20]
Comment