Java LinkedBlockingDeque addLast() methodThe addLast() method of LinkedBlockingDeque class adds the specified elements at the end of this deque, without exceeding the capacity. Syntax:Parameters:e - this is the element to be added. Specified By:The addLast() method of LinkedBlockingDeque class is specified by :
Throws:The add() method throws: NullPointerException - if the specified element e, is null. IllegalStateException - if this deque is full Example 1Test it NowOutput: [1, 2, 3, 4, 5] After inserting 10 at Last position [1, 2, 3, 4, 5, 10] Example 2Test it NowOutput: 1. Disha 2. Tanmay 3. Prachi 4. Garvit After adding string at last position : 1. Disha 2. Tanmay 3. Prachi 4. Garvit 5. Diya Example 3Test it NowOutput: Exception in thread "main" java.lang.IllegalStateException: Deque full at java.util.concurrent.LinkedBlockingDeque.addFirst(LinkedBlockingDeque.java:326) at com.javaTpoint.LinkedBlockingDequeAddLastExample3.main(LinkedBlockingDequeAddLastExample3.java:12) Example 4Test it NowOutput: 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 com.javaTpoint.LinkedBlockingDequeAddLastExample4.main(LinkedBlockingDequeAddLastExample4.java:11) dr Next TopicJava Linkedblockingdeque |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India