Java LinkedBlockingDeque addFirst() methodLast Updated : 17 Mar 2025 The addFirst() method of LinkedBlockingDeque class inserts the specified element at the front of this LinkedBlockingDeque. This method throws IllegalStateException if the specified element is null. Syntax:Parameters:e- It is the element to add Specified By:The addFirst() method of ConcurrentLinkedQueue class is specified by :
Throws:NullPointerException: This exception will throw if the specified element e is null. IllegalStateException: This exception will throw if this deque is full. Example 1Output: [1, 2, 3, 4, 5] After inserting 10 at first position [10, 1, 2, 3, 4, 5] Example 2Output: 1. Disha 2. Tanmay 3. Prachi 4. Garvit After adding string : 1. Diya 2. Disha 3. Tanmay 4. Prachi 5. Garvit Example 3Output: Exception in thread "main" java.lang.IllegalStateException: Deque full at java.util.concurrent.LinkedBlockingDeque.addFirst(LinkedBlockingDeque.java:326) at com.javaTpoint.LinkedBlockingDequeAddFirstExample3.main (LinkedBlockingDequeAddFirstExample3.java:13) Next TopicLinkedblockingdeque add() |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India