The offer(E e) method of LinkedBlockingDeque inserts the element passed in the parameter to the end of the Deque. If the container’s capacity has exceeded, then it does not returns an exception as in case of add() and addFirst() function.
public boolean offer(E e)
Parameters: This method accepts a mandatory parameter e which is the element to be inserted in the end of the LinkedBlockingDeque.
Returns: This method returns true if the element has been inserted, else it returns false.
Below programs illustrate offer() method of LinkedBlockingDeque:
The element 10 cannot be inserted as capacity is full Linked Blocking Deque: [7855642, 35658786, 5278367, 74381793]
The element 'hii' cannot be inserted as capacity is full Linked Blocking Deque: [abc, gopu, geeks, richik]
- LinkedBlockingQueue | offer() Method in JAVA
- PriorityBlockingQueue offer() method in Java
- LinkedTransferQueue offer() method in Java
- PriorityQueue offer() Method in Java
- ArrayBlockingQueue offer() Method in Java
- ArrayDeque offer() Method in Java
- Deque offer() method in Java
- ConcurrentLinkedQueue offer() method in Java
- Queue offer() method in Java
- DelayQueue offer() method in Java with Examples
- ConcurrentLinkedDeque offer() method in Java with Examples
- LinkedBlockingDeque add() method in Java
- LinkedBlockingDeque pop() method in Java
- LinkedBlockingDeque contains() method in Java
- LinkedBlockingDeque take() method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.