ConcurrentLinkedDeque contains() method in Java with Examples Last Updated : 20 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The java.util.concurrent.ConcurrentLinkedDeque.contains() method is an inbuilt method in Java which checks if the specified element, passed as a parameter, is present in the deque or not. Syntax: public boolean contains(Object elem) Parameters: The method accepts a parameter elem which checks if the specified element is present in the deque or not. Return Value: The function returns True if the element is present in the deque and returns False otherwise. Below programs illustrate the ConcurrentLinkedDeque.contains() method: Program 1: Java // Java Program to Demonstrate contains() // 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); // Check if GFG is present using contains() if (cld.contains("GFG")) { // Displaying message System.out.println("GFG is present"); } else { // Displaying message System.out.println("GFG is not present"); } } } Output: ConcurrentLinkedDeque: [Welcome, To, Geeks, 4, Geeks] GFG is not present Program 2: Java // Java Program to Demonstrate contains() // 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); // Check if Geeks is present using contains() if (cld.contains("Geeks")) { // Displaying message System.out.println("Geeks is present"); } else { // Displaying message System.out.println("Geeks not present"); } } } Output: ConcurrentLinkedDeque: [Welcome, To, Geeks, 4, Geeks] Geeks is present Reference: https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/ConcurrentLinkedDeque.html#contains-java.lang.Object- Comment More infoAdvertise with us Next Article ConcurrentLinkedDeque contains() method in Java with Examples A Aishwarya Jayashankar Follow Improve Article Tags : Java Practice Tags : Java Similar Reads 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 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 BlockingDeque contains() method in Java with Examples The contains(Object o) method of BlockingDeque checks if the passed element in the parameter exists in the container or not. It returns true if the element exists in the container else it returns a false value. Syntax: public boolean contains(Object o) Parameters: This method accepts a mandatory par 2 min read ConcurrentLinkedDeque isEmpty() method in Java with Examples The java.util.concurrent.ConcurrentLinkedDeque.isEmpty() is an in-built function in Java which checks whether the deque contains elements or not. Syntax: public boolean isEmpty() Parameters: The function does not accepts any parameter. Return: This method returns a boolean value stating whether this 1 min read ConcurrentHashMap contains() method in Java with Examples The contains() method of Java.util.ConcurrentHashMap is used to check whether if some key maps into the specified value in this table. It is a legacy method of performing a particular task. The operation is similar to containsValue() Method of ConcurrentHashMap. Syntax: ConcurrentHashMap.contains(Ob 2 min read Like