LinkedTransferQueue remove() method in Java
The java.util.concurrent.LinkedTransferQueue.remove() method is an in-built function in Java which is used to remove an element if it is present in this queue.
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.
Parameters: The function accepts a single parameter o i.e. the object to be removed.
Return Value: The function returns a true boolean value on successful removal of the object, otherwise returns false.
Below programs illustrate LinkedTransferQueue.remove() method:
Program 1: The element to be removed is present in the queue.
The elements in the queue are: 1 2 3 4 5 Remaining elements in queue : 2 3 4
Program 2: The element to be removed is not present in the queue.
The elements in the queue are: 10 11 12 13 14 15 Remaining elements in queue : 10 11 12 13 14 15