VOOZH about

URL: https://www.geeksforgeeks.org/java/blockingdeque-pollfirst-method-in-java-with-examples/

⇱ BlockingDeque pollFirst() method in Java with examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

BlockingDeque pollFirst() method in Java with examples

Last Updated : 12 Jul, 2025
The pollFirst() method of BlockingDeque returns the front element in the Deque container, and deletes it. It returns null if the container is empty. Syntax:
public E pollFirst()
Parameters: This method does not accept any parameters. Returns: This method returns front element in the Deque container if the container is not empty and deletes the element. It returns null if the container is empty. Note: The pollFirst() method of BlockingDeque has been inherited from the LinkedBlockingDeque class in Java. Below programs illustrate pollFirst() method of BlockingDeque: Program 1:
Output:
Blocking Deque: [74381793, 5278367, 35658786, 7855642]
Front element in Deque: 74381793
Blocking Deque: [5278367, 35658786, 7855642]
Program 2:
Output:
Blocking Deque: [7855642, 35658786, 5278367, 74381793]
Front element in Deque: null
Reference: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingDeque.html#pollFirst(long, %20java.util.concurrent.TimeUnit)
Comment