110
Java ConcurrentLinkedQueue remove() Method
The remove() method of ConcurrentLinkedQueue class removes the specified element from the queue if that element is present in the queue.
Syntax:
Parameters:
The parameter ‘o’ is the element to be removed from the queue if it is present.
Specified By:
The remove () method of ConcurrentLinkedQueue class is specified by:
- remove in interface Collection<E>.
Overrides:
The remove () method of ConcurrentLinkedQueue class overrides:
- remove in class AbstractCollection<E>.
Return Value:
The remove() method returns a Boolean value corresponding to this Object ‘o’:
- It returns true if the element is present in the queue and the queue is changed as a result of this queue.
- Else it returns false.
Example 1
Output:
Elements in queue : [12, 98, 122, 102, 112] Remaining elements in queue : [12, 98, 112]
Example 2
Output:
Cake Pulses Sugar Salt Basmati Rice Aata New List : [Pulses, Sugar, Basmati Rice, Aata]
Example 3
Output:
Elements in queue : [12, 98, 122, 102, 112]
Next TopicJava ConcurrentLinkedQueue