Java LinkedBlockingDeque getFirst() method21 Mar 2025 | 2 min read The getFirst() method of LinkedBlockingDeque class returns the first element of this deque but does not withdraw it. Syntax:Parameters:NA Specified By:The getFirst() method of LinkedBlockingDeque class is specified by getFirst() method in interface Deque<E>. Return Value:The getFirst() method returns the first element of this deque. Throws:The getFirst() method throws NoSuchElementException, if this deque is empty. Example 1Output: First element in the Queue is : 987 Example 2Output: Exception in thread "main" java.util.NoSuchElementException at java.util.concurrent.LinkedBlockingDeque.getFirst(Unknown Source) Example 3Output: Mansi got 41 bonus_points. Vaibhav got 33 bonus_points. Shraddha got 31 bonus_points. Vishal got 27 bonus_points. Shalu got 26 bonus_points. Abhi got 19 bonus_points. On the basis of bonus points, Promotion is awarded to : Mansi Next TopicJava Linkedblockingdeque |
Java LinkedBlockingDeque Method The offerFirst () method of LinkedBlockingDeque class adds the defined elements at the front of this deque. Syntax: public boolean offerFirst(E e) public boolean offerFirst(E e, long timeout, TimeUnit unit) throws InterruptedException Parameters: e - It is the element to be added. timeout - It is the time...
3 min read
Java LinkedBlockingDeque Method The method of LinkedBlockingDeque class retrieves this deque's first element, but doesn't remove it. The method returns null if this deque is empty. Syntax: public E Parameters: NA Specified By: The method of LinkedBlockingDeque class is specified by method in interface Deque<E>. Return Value: The ...
3 min read
Java LinkedBlockingDeque method The method of LinkedBlockingDeque class automatically withdraws all the elements from this deque. The deque becomes empty, after calling this method. Syntax: public void Parameters: NA Specified By: The method of class LinkedBlockingDeque is specified by method in interface Collection<E>. Override: The method of class...
3 min read
Java LinkedBlockingDeque Method The method of LinkedBlockingDeque class retrieves the last element of this deque, and also removes it. This method returns null if this deque is empty. The pollLast(long timeout, TimeUnit unit) method of LinkedBlockingDeque class retrieves the last element of this deque, awaiting...
2 min read
Java LinkedBlockingDeque Method The method of LinkedBlockingDeque class adds the defined element at the tail of this deque. Syntax: public boolean offer(E e) public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException Parameters: e - It is the element to be added. timeout - It is the time till...
4 min read
Java LinkedBlockingDeque Method The method of LinkedBlockingDeque class adds the defined elements at the end of this deque, only if the deque's capacity allows so. Syntax: public boolean offerLast(E e) public boolean offerLast(E e, long timeout, TimeUnit unit) throws InterruptedException Parameters: e - It is the element to be...
2 min read
Java LinkedBlockingDeque method The method of LinkedBlockingDeque class inserts the specified element at the tail of this LinkedBlockingDeque. The method overrides the add in class AbstractQueue<E> Syntax: public boolean add(E e) Parameters: e- It is the element to add Specified By: The method of ConcurrentLinkedQueue class is specified...
2 min read
Java LinkedBlockingDeque Method The method of LinkedBlockingDeque() class removes all the elements present in this queue and adds them to the provided collection. Syntax: public int drainTo(Collection<? super E> c) public int drainTo(Collection<? super E> c, int maxElements) Parameters: c - this is the collection to which elements are...
3 min read
Java LinkedBlockingDeque Method The method of LinkedBlockingDeque class retrieves this deque's last element, but doesn't remove it. The method returns null if this deque is empty. Syntax: public E peekLast () Parameters: NA Specified By: The peekLast () method of LinkedBlockingDeque class is specified by method in interface Deque<E>. Return...
3 min read
Java LinkedBlockingDeque Method The method of LinkedBlockingDeque class retrieves the first element of this deque, and also removes it. The method returns null if this deque is empty. The pollFirst(long timeout, TimeUnit unit) method of LinkedBlockingDeque class retrieves the first element of this deque, awaiting...
2 min read
We request you to subscribe our newsletter for upcoming updates.
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