The Java.util.PriorityQueue.remove() method is used to remove a particular element from a PriorityQueue.
Parameters: The parameter O is of the type of PriorityQueue and specifies the element to be removed from the PriorityQueue.
Return Value: This method returns True if the specified element is present in the Queue else it returns False.
Below programs illustrate the Java.util.PriorityQueue.remove() method:
Initial PriorityQueue: [For, Geeks, To, Welcome, Geeks] PriorityQueue after removing elements: [Geeks, To]
Initial PriorityQueue: [5, 10, 30, 20, 15] PriorityQueue after removing elements: [10, 20, 15]
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. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.