ConcurrentLinkedDeque poll() method in Java with Example Last Updated : 24 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 the container is not empty and deletes it. It returns null if the container is empty. Below programs illustrate poll() method of ConcurrentLinkedDeque: Program 1: Java // Java Program Demonstrate poll() // method of ConcurrentLinkedDeque import java.util.concurrent.ConcurrentLinkedDeque; import java.util.*; public class GFG { public static void main(String[] args) { // create object of ConcurrentLinkedDeque ConcurrentLinkedDeque<Integer> CLD = new ConcurrentLinkedDeque<Integer>(); // Add numbers to end of ConcurrentLinkedDeque CLD.add(7855642); CLD.add(35658786); CLD.add(5278367); CLD.add(74381793); // Print the queue System.out.println("ConcurrentLinkedDeque: " + CLD); System.out.println("Front element in Deque: " + CLD.poll()); // One element is deleted as poll was called System.out.println("ConcurrentLinkedDeque: " + CLD); } } Output: ConcurrentLinkedDeque: [7855642, 35658786, 5278367, 74381793] Front element in Deque: 7855642 ConcurrentLinkedDeque: [35658786, 5278367, 74381793] Program 2: Java // Java Program Demonstrate poll() // method of ConcurrentLinkedDeque // when Deque is empty import java.util.concurrent.ConcurrentLinkedDeque; import java.util.*; public class GFG { public static void main(String[] args) { // create object of ConcurrentLinkedDeque ConcurrentLinkedDeque<Integer> CLD = new ConcurrentLinkedDeque<Integer>(); // Add numbers to end of ConcurrentLinkedDeque CLD.add(7855642); CLD.add(35658786); CLD.add(5278367); CLD.add(74381793); // Print the queue System.out.println("ConcurrentLinkedDeque: " + CLD); // empty deque CLD.clear(); System.out.println("Front element in Deque: " + CLD.poll()); } } Output: ConcurrentLinkedDeque: [7855642, 35658786, 5278367, 74381793] Front element in Deque: null Comment More infoAdvertise with us Next Article ConcurrentLinkedDeque push() method in Java with Examples M MerlynShelley Follow Improve Article Tags : Java Technical Scripter Technical Scripter 2018 Java-Collections Java - util package Java-Functions Java-ConcurrentLinkedDeque +3 More Practice Tags : JavaJava-Collections 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 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 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 offer() method in Java with Examples 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 de 2 min read ConcurrentLinkedDeque remove() method in Java with Examples The java.util.concurrent.ConcurrentLinkedDeque.remove() is an in-built function in Java which is used to remove an element from this deque.Syntax: public E remove() or public boolean remove(Object o) Parameters: The first overload of this method does not accepts any parameter. However the second ove 2 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