VOOZH about

URL: https://www.geeksforgeeks.org/java/blockingdeque-offerlast-method-in-java-with-examples/

⇱ BlockingDeque offerLast() method in Java with examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

BlockingDeque offerLast() method in Java with examples

Last Updated : 12 Jul, 2025
The offerLast(E e) method of BlockingDeque inserts the element passed in the parameter at the end of the Deque container. If the container's capacity has exceeded, then it does not returns an exception as in case of add() and addLast() function. Syntax:
public boolean offerLast(E e)
Parameters: This method accepts a mandatory parameter e which is the element to be inserted at the end of the BlockingDeque. Returns: This method returns true if the element has been inserted, else it returns false. Note: The offerLast() method of BlockingDeque has been inherited from the LinkedBlockingDeque class in Java. Below programs illustrate offerLast() method of BlockingDeque: Program 1:
Output:
The element 10 cannot be inserted as capacity is full
Blocking Deque: [7855642, 35658786, 5278367, 74381793]
Program 2:
Output:
The element 'hii' cannot be inserted as capacity is full
Blocking Deque: [abc, gopu, geeks, richik]
Reference: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingDeque.html#offerLast(E)
Comment