ConcurrentLinkedDeque offer() method in Java with Examples Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The java.util.concurrent.ConcurrentLinkedDeque.offer() method is an inbuilt method in Java which inserts the specified element, passed as a parameter, to the deque. Syntax: public boolean offer(E elem) Parameters: The method accepts a parameter elem which species the element to be inserted to 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.offer() method: Program 1: Java // Java Program to Demonstrate offer() // method of ConcurrentLinkedDeque import java.util.concurrent.*; class GFG { public static void main(String[] args) { // Creating an empty Deque ConcurrentLinkedDeque<String> cld = new ConcurrentLinkedDeque<String>(); // Add elements into the Deque cld.add("Welcome"); cld.add("To"); cld.add("Geeks"); cld.add("4"); cld.add("Geeks"); // Displaying the Deque System.out.println("ConcurrentLinkedDeque: " + cld); // Insert an element using offer() if (cld.offer("GFG")) { // Displaying message System.out.println("Element Inserted"); } else { // Displaying message System.out.println("Element not Inserted"); } // Displaying the Deque System.out.println("ConcurrentLinkedDeque: " + cld); } } Output: ConcurrentLinkedDeque: [Welcome, To, Geeks, 4, Geeks] Element Inserted ConcurrentLinkedDeque: [Welcome, To, Geeks, 4, Geeks, GFG] Java // Java Program to Demonstrate offer() // method of ConcurrentLinkedDeque import java.util.concurrent.*; class GFG { public static void main(String[] args) { // Creating an empty Deque ConcurrentLinkedDeque<String> cld = new ConcurrentLinkedDeque<String>(); // Add elements into the Deque cld.add("Welcome"); cld.add("To"); cld.add("Geeks"); cld.add("4"); cld.add("Geeks"); // Displaying the Deque System.out.println("ConcurrentLinkedDeque: " + cld); try { // Insert null element using offer() cld.offer(null); } catch (Exception e) { System.out.println(e); } } } Output: ConcurrentLinkedDeque: [Welcome, To, Geeks, 4, Geeks] java.lang.NullPointerException Reference: https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/ConcurrentLinkedDeque.html#offer-E- Comment More infoAdvertise with us Next Article ConcurrentLinkedDeque pop() method in Java with Examples A Aishwarya Jayashankar Follow Improve Article Tags : Java Practice Tags : Java Similar Reads ConcurrentLinkedDeque pop() method in Java with Examples The Java.util.ConcurrentLinkedDeque.pop() method in Java is used to pop an element from the ConcurrentLinkedDeque. The element is popped from the top of the ConcurrentLinkedDeque and is removed from the same.Syntax: ConcurrentLinkedDeque.pop() Parameters: The method does not take any parameters.Retu 2 min read ConcurrentLinkedDeque peek() method in Java with Example The java.util.ConcurrentLinkedDeque.peek() method in Java is used to retrieve or fetch the element at the head of the Deque. The element retrieved does not get deleted or removed from the Deque instead the method just returns it. If no element is present in the deque then Null is returned. Syntax: A 2 min read ConcurrentLinkedDeque poll() method in Java with Example The poll() method of ConcurrentLinkedDeque returns the front element in the Deque container and deletes it. It returns null if the container is empty. Syntax: public E poll() Parameters: This method does not accept any parameters. Returns: This method returns front element of the Deque container if 2 min read ConcurrentLinkedDeque push() method in Java with Examples The push() method of ConcurrentLinkedDeque class is an in-built function in Java which pushes an element onto the stack represented by this deque (in other words, at the head of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success an 2 min read ConcurrentLinkedDeque addAll() method in Java with Examples The addAll(Collection col) of ConcurrentLinkedDeque which takes col as a parameter, where col is a Collection of elements (List, ArrayList, LinkedList etc). This entire Collection gets appended or added to the end of the Dequeue. This method just like add() method returns true if the Collection gets 3 min read ConcurrentLinkedDeque iterator() method in Java with Example The Java.util.concurrent.ConcurrentLinkedDeque.iterator() method is used to return an iterator of the same elements as that of the ConcurrentLinkedDeque. The elements are returned in random order from what was present in the deque. Syntax: Iterator iterate_value = ConcurrentLinkedDeque.iterator(); P 2 min read Like