ConcurrentLinkedDeque pollLast() method in Java
The java.util.concurrent.ConcurrentLinkedDeque.pollLast() is an in-built method in Java which retrieves the last element of this deque and removes it. If the deque is empty, the method returns NULL.
Parameters: The function accepts no parameters.
Return Values:The function returns the last element of this deque. If this deque is empty, the function returns NULL.
Below program illustrates the use of pollFirst() method:
Program 1: This program involves deque with Integer elements.
Elements inthe LinkedDeque: [475, 1009, 70, 12] Element removed : 12 Elements inthe LinkedDeque: [475, 1009, 70]
Program 2: This program involves deque with String elements.
Elements inthe LinkedDeque: [Geeks, Gfg, Geeks, GFG] Element removed : GFG Elements inthe LinkedDeque: [Geeks, Gfg, 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.