remove(Object): This method is available in java.util.Vector class of Java.
Syntax:
boolean java.util.Vector.remove(Object o)
This method takes one argument. This method removes the first occurrence of the specified element in this Vector. If the Vector does not contain the element, it is unchanged.
Parameters: One parameter is required for this method.
o: the element to be removed from this Vector, if present.
Returns: true if the Vector contained the specified element.
Exceptions: NA
Approach
Java
import java.util.Vector;public class Vectorremove2 {public static void main(String[] args) {Vector<String> vector = new Vector<>();vector.add("Hello");vector.add("Java");vector.add("C++");vector.add("Program");Object o = "C++";System.out.println(vector.remove(o));}}
Output:
true
No comments:
Post a Comment