ConcurrentLinkedDeque clear() method in Java Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 ConcurrentLinkedDeque.clear() method: Program 1: Java // Java Program to Demonstrate clear() // 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); // Remove all elements of the Deque using clear() cld.clear(); // Displaying message System.out.println("\nConcurrentLinkedDeque cleared\n"); // Displaying the Deque System.out.println("ConcurrentLinkedDeque: " + cld); } } Output: ConcurrentLinkedDeque: [Welcome, To, Geeks, 4, Geeks] ConcurrentLinkedDeque cleared ConcurrentLinkedDeque: [] Program 2: Java // Java Program to Demonstrate clear() // method of ConcurrentLinkedDeque import java.util.concurrent.*; class GFG { public static void main(String[] args) { // Creating an empty Deque ConcurrentLinkedDeque<Integer> cld = new ConcurrentLinkedDeque<Integer>(); // Add elements into the Deque cld.add(10); cld.add(20); cld.add(30); cld.add(40); cld.add(50); // Displaying the Deque System.out.println("ConcurrentLinkedDeque: " + cld); // Remove all elements of the Deque using clear() cld.clear(); // Displaying message System.out.println("\nConcurrentLinkedDeque cleared\n"); // Displaying the Deque System.out.println("ConcurrentLinkedDeque: " + cld); } } Output: ConcurrentLinkedDeque: [10, 20, 30, 40, 50] ConcurrentLinkedDeque cleared ConcurrentLinkedDeque: [] Reference: https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/ConcurrentLinkedDeque.html#clear-- Comment More infoAdvertise with us Next Article ConcurrentLinkedDeque element() method in Java A Aishwarya Jayashankar Follow Improve Article Tags : Java Practice Tags : Java Similar Reads ConcurrentLinkedDeque element() method in Java 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 metho 2 min read ConcurrentLinkedDeque pollLast() method in Java The java.util.concurrent.ConcurrentLinkedDeque.pollLast() is an in-built method in Java which retrieves the last element of this deque and removes it. If the deque is empty, the method returns NULL. Syntax: Conn_Linked_Deque.pollLast() Parameters: The function accepts no parameters. Return Values:Th 2 min read ConcurrentLinkedDeque pollFirst() method in Java The java.util.concurrent.ConcurrentLinkedDeque.pollFirst() is an in-built method in Java which retrieves the first element of this deque and removes it. If the deque is empty, the method returns NULL. Syntax: Conn_Linked_Deque.pollFirst() Parameters: This function does not accepts any parameter. Ret 2 min read ConcurrentLinkedDeque in Java The ConcurrentLinkedDeque class in Java is a part of the Java Collection Framework and implements the Collection interface and the AbstractCollection class. It belongs to java.util.concurrent package. It is used to implement Deque with the help of LinkedList concurrently.Iterators and spliterators a 10 min read ConcurrentSkipListSet clear() method in Java The java.util.concurrent.ConcurrentSkipListSet.clear() method is an in-built function in Java which removes all the elements from this set. Syntax: ConcurrentSkipListSet.clear() Parameters: The function does not accept any parameter. Return Value: The function does not return anything. Below program 2 min read ConcurrentLinkedDeque removeLast() method in Java The ConcurrentLinkedDeque.removeLast() is an in-built function in Java which removes the last element in the deque. The function throws a NoSuchElementException if this deque is empty. Syntax: Conn_Linked_Deque.removeLast() Parameters: The function does not accepts any parameter. Return Values: The 2 min read Like