ConcurrentLinkedDeque offerLast() Method in Java
The java.util.concurrent.ConcurrentLinkedDeque.offerLast() method is an inbuilt method in Java which inserts the specified element, passed as a parameter, to the end of the deque.
Parameters: The method accepts a parameter elem which species the element to be inserted to the end of the deque.
Return Value: The function returns True if the element is successfully added into the deque and returns False otherwise.
Exception: The function throws a NullPointerException if the passed parameter is NULL.
Below programs illustrate the ConcurrentLinkedDeque.offerLast() method:
Elements in Deque: [Welcome, To, Geeks, 4, Geeks] The Last element is: Geeks The Inserted element is: GFG Elements in Deque: [Welcome, To, Geeks, 4, Geeks, GFG] The Last element is: GFG
Elements in Deque: [12, 43, 29, 16, 70] The Last element is: 70 java.lang.NullPointerException The Inserted element is: 24 Elements in Deque: [12, 43, 29, 16, 70, 24] The Last element is: 24
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.