Javatpoint Logo
Javatpoint Logo

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

Test it Now

Output:

Elements in queue : [12, 98, 122, 102, 112]
Remaining elements in queue : [12, 98, 112]

Example 2

Test it Now

Output:

Cake
Pulses
Sugar
Salt
Basmati Rice
Aata
New List : [Pulses, Sugar, Basmati Rice, Aata]

Example 3

Test it Now

Output:

Elements in queue : [12, 98, 122, 102, 112]






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA