The Java.util.Stack.remove(Object o) method is used to remove any particular element from the Stack.
Parameters: This method accepts a mandatory parameter o is of the object type of Stack and specifies the element to be removed from the Stack.
Return Value: Returns True if the specified element is found and removed from the Stack, else False.
Below program illustrate the Java.util.Stack.remove(Object o) method:
Stack: [Geeks, for, Geeks, 10, 20] Was 20 removed: true Final Stack: [Geeks, for, Geeks, 10]
Stack: [10, 20, 30, 40, 50] Was 100 removed: false Final Stack: [10, 20, 30, 40, 50]
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.