The remove() method of DelayQueue class in Java is used to remove a single instance of the given object say obj from this DelayQueue if it is present. It returns true if the given element is removed successfully otherwise it returns false.
public boolean remove(Object obj)
Parameters: This method takes a single object obj as parameter which is to be removed from this DealyQueue.
Return Value: It returns a boolean value which is true if the element has been successfully deleted otherwise it returns false.
Below program illustrate the remove() method of DelayQueue in Java:
Initial Size : 1 Size after removing : 0
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.