GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — BlockingDeque add() method in Java with Examples - GeeksforGeeks BlockingDeque add() method in Java with ExamplesLast Updated : 12 Jul, 2025 The add(E e) method of BlockingDeque inserts the element passed in the parameter to the end of the Deque is there is space. If the BlockingDeque is capacity restricted and no space is left for insertion, it returns an IllegalStateException. It works exactly in the same way as addLast() method does.
Syntax:
public void add(E e)Parameters: This method accepts a mandatory parameter e which is the element to be inserted in the end of the BlockingDeque. Returns: This method does not returns anything. Exception:
Output:
Program 2:
Blocking Deque: [7855642, 35658786, 5278367, 74381793]
Exception in thread "main" java.lang.IllegalStateException: Deque full
at java.util.concurrent.LinkedBlockingDeque.addLast(LinkedBlockingDeque.java:335)
at java.util.concurrent.LinkedBlockingDeque.add(LinkedBlockingDeque.java:633)
at GFG.main(GFG.java:24)
Program 3:
Output:
Exception in thread "main" java.lang.NullPointerException
at java.util.concurrent.LinkedBlockingDeque.offerLast(LinkedBlockingDeque.java:357)
at java.util.concurrent.LinkedBlockingDeque.addLast(LinkedBlockingDeque.java:334)
at java.util.concurrent.LinkedBlockingDeque.add(LinkedBlockingDeque.java:633)
at GFG.main(GFG.java:23)
Reference: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingDeque.html#add(E)Comment Explore |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |