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 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: public Boolean addFirst(E e) Parameters: e- It is the element to add Specified By: The method of ConcurrentLinkedQueue class is...
1 min read
Java LinkedBlockingDeque method The method of LinkedBlockingDeque class returns an iterator over the elements of this queue. The elements are returned in the reverse sequential order. Syntax: public Iterator<E> Parameters: NA Specified By: The method of LinkedBlockingDeque class is specified by method of interface Deque<E>. Return Value: The ...
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 is used to check the presence of the specified element in the deque. If the element is present in the deque, then this method returns true otherwise it returns false. Syntax: public boolean contains(Object o) Parameters: o - this is the object that...
2 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 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 is used to add all the elements of the specified collection at the end of this deque. This method overrides in class AbstractQueue<E>. Syntax: public boolean addAll(Collection<? extends E> c Parameters: c- the elements to be added to this...
3 min read
Java LinkedBlockingDeque Method The method of LinkedBlockingDeque class retrieves the head of the queue corresponding to this deque, and also removes it. This method returns null if this deque is empty. The poll(long timeout, TimeUnit unit) method of LinkedBlockingDequeclass retrieves the head of the queue...
2 min read
Methods class provides several methods like addFirst(), add(), clear(), element(), getLast(), peek(), etc. addFirst() add() addAll() addLast() clear() contains() descendingIterator() drainTo() element() getFirst() getLast() iterator() offerFirst() offerLast() offer() peek() peekFirst() peekLast() pollFirst() pollLast() poll() pop() TopicLinkedblockingdeque addFirst() ...
1 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