The java.util.concurrent.ConcurrentLinkedDeque.remove() is an in-built function in Java which is used to remove an element from this deque.
public E remove() or public boolean remove(Object o)
Parameters: The first overload of this method does not accepts any parameter. However the second overload of this method accepts an element o as parameter which is to be removed from this ConcurrentLinkedDeque.
Return Value: This method returns the element removed if no particular element is specified as parameter. if an element is specified as parameter, then it returns a boolean value stating whether this element is removed or not.
Exception: The first overload of this function throws a NoSuchElementException if this deque is empty. Whereas the second overload throws NullPointerException if the specified element is null.
Below programs illustrate the ConcurrentLinkedDeque.remove() method:
Existing ConcurrentLinkedDeque: [40, 50, 60, 70, 80] Element removed: 40 Modified ConcurrentLinkedDeque: [50, 60, 70, 80]
Elements inthe LinkedDeque: [GFG, Gfg, GeeksforGeeks, Geeks] Gfg removed: true Elements inthe LinkedDeque: [GFG, GeeksforGeeks, Geeks]
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.