BlockingDeque element() method in java with examples
The element() method of BlockingDeque returns the element at the front the container. It does not delete the element in the container. This method returns the head of the queue represented by this deque.
public void element()
Parameters: This method does not accept any parameter.
Returns: This method returns the head of the queue represented by this deque.
Note: The element() method of BlockingDeque has been inherited from the LinkedBlockingDeque class in Java.
Below programs illustrate element() method of BlockingDeque:
Blocking Deque: [10, 20, 30, 40] Blocking Deque front element: 10
Blocking Deque: [ab, cd, fg, xz] Blocking Deque front element: ab
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.