The java.util.concurrent.ConcurrentLinkedDeque.addLast() is an in-built function in Java which inserts the specified element to the end of the deque.
Parameter: The method accepts only a single parameter elem which is to be added to the end of the ConcurrentLinkedDeque.
Return Value: The function has no return value.
Exception: The method will throw NullPointerException when the parameter passed to the function is null. Due to its bounded nature, this method will never throw IllegalStateException or return false.
Below programs illustrate the use of java.util.concurrent.ConcurrentLinkedDeque.addLast() method:
Program 1: This program involves a ConcurrentLinkedDeque of Integer type.
Initial Elements inthe LinkedDeque: [12, 110, 55, 76] Initial Elements inthe LinkedDeque: [12, 110, 55, 76, 21]
Program 2: This program involves a ConcurrentLinkedDeque of Integer type with Exception Handling when null is passed as parameter to the function.
Initial Elements inthe LinkedDeque: [Geeks, Geek, Gfg, Contribute] NullPointerExceptionthrown Initial Elements inthe LinkedDeque: [Geeks, Geek, Gfg, Contribute, Sudo Placement]
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.