![]() |
VOOZH | about |
The java.util.concurrent.ConcurrentLinkedDeque.element() is an in-built function in java which retrieves but does not remove the head of the queue represented by deque i.e the first element of deque.
Syntax:
conn_linked_deque.element()
Parameter: This method has no parameters.
Return Value: This method returns the first element in the deque.
Exception: This method will throw NoSuchElementException if the deque is empty.
Below programs illustrate the ConcurrentLinkedDeque.element() method:
Program 1: This program involves a ConcurrentLinkedDeque of Integer type.
ConcurrentLinkedDeque: [12, 70, 1009, 475] The Head of deque is: 12
Program 2: This program involves a ConcurrentLinkedDeque of String type.
ConcurrentLinkedDeque: [Gfg, Geeks, Programming, contribute] The Head of deque is: Gfg