VOOZH about

URL: https://www.geeksforgeeks.org/java/arraydeque-offerlast-method-in-java/

⇱ ArrayDeque offerLast() Method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

ArrayDeque offerLast() Method in Java

Last Updated : 11 Jul, 2025
The Java.util.ArrayDeque.offerLast(Object element) method in Java is used to add a specific element at the end of this Deque. The function is similar to the addLast(), add() and offer() method of ArrayDeque in Java. Syntax:
Array_Deque.offerLast(Object element)
Parameters: The parameter element is of the type ArrayDeque and refers to the element to be added at the end of the Deque. Return Value: The function returns True if the element is successfully added into the deque else it returns false. Exceptions: The method throws NullPointerException if the passed parameter is NULL. Below programs illustrate the Java.util.ArrayDeque.offerLast() method: Program 1: Adding String elements into the Deque.
Output:
Initial Deque: [Welcome, To, Geeks, 4, Geeks]
Final Deque: [Welcome, To, Geeks, 4, Geeks, Hello, World]
Program 2: Adding Integer elements into the Deque.
Output:
Initial Deque: [10, 15, 30, 20, 5]
Final Deque: [10, 15, 30, 20, 5, 1658, 2458]
Comment