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: