VOOZH about

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

⇱ PriorityBlockingQueue remove() method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

PriorityBlockingQueue remove() method in Java

Last Updated : 11 Jul, 2025
The remove(Object o) method of PriorityBlockingQueue is used to delete an element from this queue. This method removes a single instance of the element passed as the parameter, if it is present. It returns true if and only if the element was removed, else it returned false. Syntax:
public boolean remove(Object o)
Parameter: This method accepts a mandatory parameter o which is the element to be removed from this queue, if present. Return Value: This method returns true if the specified element was removed successfully. Else this method returns false. Below programs illustrate remove() method in PriorityBlockingQueue: Program 1:
Output:
Queue: [1, 2, 3, 4]

2 removed: true
Queue: [1, 4, 3]

5 removed: false
Queue: [1, 4, 3]
Output:
Queue: [A Computer, Portal, Geeks, forGeeks]

Geeks removed: true
Queue: [A Computer, Portal, forGeeks]

SandeepJain removed: false
Queue: [A Computer, Portal, forGeeks]
Comment