ConcurrentLinkedDeque element() method in Java Last Updated : 16 Apr, 2021 Comments Improve Suggest changes Like Article Like Report 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. JAVA // Java example illustrating // ConcurrentLinkedDeque element() method import java.util.concurrent.*; class ConcurrentLinkedDequeDemo { public static void main(String[] args) { // Create a ConcurrentLinkedDeque // using ConcurrentLinkedDeque() constructor ConcurrentLinkedDeque<Integer> cld = new ConcurrentLinkedDeque<Integer>(); cld.add(12); cld.add(70); cld.add(1009); cld.add(475); // Displaying the existing LinkedDeque System.out.println("ConcurrentLinkedDeque: " + cld); // Displaying the head of deque System.out.println("The Head of deque is: " + cld.element()); } } Output: ConcurrentLinkedDeque: [12, 70, 1009, 475] The Head of deque is: 12 Program 2: This program involves a ConcurrentLinkedDeque of String type. JAVA // Java example illustrating // ConcurrentLinkedDeque element() method import java.util.concurrent.*; class ConcurrentLinkedDequeDemo { public static void main(String[] args) { // Create a ConcurrentLinkedDeque // using ConcurrentLinkedDeque() constructor ConcurrentLinkedDeque<String> cld = new ConcurrentLinkedDeque<String>(); cld.add("Gfg"); cld.add("Geeks"); cld.add("Programming"); cld.add("contribute"); // Displaying the existing LinkedDeque System.out.println("ConcurrentLinkedDeque: " + cld); // Displaying the head of deque System.out.println("The Head of deque is: " + cld.element()); } } Output: ConcurrentLinkedDeque: [Gfg, Geeks, Programming, contribute] The Head of deque is: Gfg Comment More infoAdvertise with us Next Article ConcurrentLinkedDeque element() method in Java K kanakasrijaathukuri Follow Improve Article Tags : Java Practice Tags : Java Similar Reads ConcurrentLinkedDeque getLast() Method in Java The java.util.concurrent.ConcurrentLinkedDeque.getLast() method is an in-built method in Java which returns the last element of the deque container. Syntax: Conn_Linked_Deque.getLast() Parameters: The method does not accept any parameter. Return Value: The method returns the last element present in 2 min read ConcurrentLinkedDeque getFirst() method in Java The java.util.concurrent.ConcurrentLinkedDeque.getFirst() method is an in-built method in Java which returns the first element of the deque container. Syntax: Conn_Linked_Deque.getFirst() Parameters: The method does not accept any parameter. Return Value: The method returns the first element present 2 min read ConcurrentLinkedDeque add() method in Java The java.util.concurrent.ConcurrentLinkedDeque.add() is an in-built function in Java which inserts the specified element at the end of the deque. Syntax: conn_linked_deque.add(elem) Parameter: The method accepts only a single parameter elem which is to be added to tail of the ConcurentLinkedDeque. R 2 min read ConcurrentLinkedDeque size() method in Java The size() method of ConcurrentLinkedDeque class in Java is used to find the number of elements present in the ConcurrentLinkedDeque container. In other words, this method tells the current capacity of the container. The value returned by this method is of integral type and in case if the container 2 min read ConcurrentLinkedDeque equals() method in Java with Example The equals() method of java.util.ConcurrentLinkedDeque class is used to compare the specified object with this ConcurrentLinkedDeque for equality. Returns true if and only if the specified object is also a ConcurrentLinkedDeque, both ConcurrentLinkedDeques have the same size, and all corresponding p 2 min read ConcurrentLinkedDeque clear() method in Java The java.util.concurrent.ConcurrentLinkedDeque.clear() method is an inbuilt method in Java which removes the elements in the Deque. Syntax: public void clear() Parameters: The method do not accepts any parameter. Return Value: The function does not return anything Below programs illustrate the Concu 2 min read ConcurrentLinkedQueue add() method in Java The add() method of ConcurrentLinkedQueue is used to insert the element, passed as parameter to add() of ConcurrentLinkedQueue, at the tail of this ConcurrentLinkedQueue. This method returns True if insertion is successful. ConcurrentLinkedQueue is unbounded, so this method will never throw IllegalS 2 min read ConcurrentLinkedQueue contains() method in Java The contains() method of ConcurrentLinkedQueue returns true if ConcurrentLinkedQueue contains the object o, passed as parameter. This method returns true if and only if this ConcurrentLinkedQueue contains at least one element e which is equal to object o passed as parameter i.e. o.equals(e). Syntax: 2 min read 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 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 Like