Java LinkedBlockingDeque element() methodLast Updated : 17 Mar 2025 The element() method of LinkedBlockingDeque class returns the head of the queue corresponding to this deque but does not withdraw it. The result returned by this method is similar to the one returned by getFirst() method. Syntax:Parameters:NA Specified By:The element() method of LinkedBlockingDeque class is specified by:
Overrides:The element() method of LinkedBlockingDeque class is overrided by element() method in class AbstractQueue<E>. Return Value:The element() method returns the head of the queue corresponding to this deque. Throws:The element() method throws NoSuchElementException, if this deque is empty. Example 1Output: Head of the Queue is : Harish Example 2Output: Hinna got 97 marks. Vinni got 87 marks. Rima got 77 marks. Topper of the class is Hinna Example 3Output: 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 com.TpointTech.LinkedBlockingDequeElementExample3.main(LinkedBlockingDequeElementExample3.java:9) Next TopicJava Linkedblockingdeque |
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