The java.util.concurrent.ConcurrentLinkedDeque.offerFirst() method is an inbuilt method in Java which inserts the specified element, passed as a parameter, in the front of the deque.
Syntax:
Conn_Linked_Deque.offerFirst(Object elem)
Parameters: The method accepts a parameter
elem which species the element to be inserted to the front of the deque.
Return Value: The function returns
True if the element is successfully added into the deque and returns
False otherwise.
Exception: The function throws a
NullPointerException if the passed parameter is
NULL.
Below programs illustrate the ConcurrentLinkedDeque.offerFirst() method:
Program 1:
Output:
Elements in Deque: [Welcome, To, Geeks, 4, Geeks]
The First element is: Welcome
The Inserted element is: GFG
Elements in Deque: [GFG, Welcome, To, Geeks, 4, Geeks]
The First element is: GFG
Program 2: