ConcurrentLinkedQueue contains() method in Java Last Updated : 26 Nov, 2018 Comments Improve Suggest changes Like Article Like Report 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: public boolean contains(Object o) Parameter: This method takes a single parameter O which represents object to check whether ConcurrentLinkedQueue contains the specified object. Returns: This method returns true if this ConcurrentLinkedQueue contains the object. Below programs illustrate contains() method of ConcurrentLinkedQueue: Example 1: Java // Java Program Demonstrate contains() // method of ConcurrentLinkedQueue import java.util.concurrent.*; public class GFG { public static void main(String[] args) { // create an ConcurrentLinkedQueue ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<String>(); // Add String to queue queue.add("Aman"); queue.add("Amar"); queue.add("Sanjeet"); queue.add("Rabi"); // Displaying the existing ConcurrentLinkedQueue System.out.println("ConcurrentLinkedQueue: " + queue); // check whether queue contains String "Aman" boolean response1 = queue.contains("Aman"); // print after applying contains method System.out.println("queue contains String \"Aman\" : " + response1); // check whether queue contains "Ram" boolean response2 = queue.contains("Ram"); // print after applying contains method System.out.println("queue contains String \"Ram\" : " + response2); } } Output: ConcurrentLinkedQueue: [Aman, Amar, Sanjeet, Rabi] queue contains String "Aman" : true queue contains String "Ram" : false Example 2: Java // Java Program Demonstrate contains() // method of ConcurrentLinkedQueue import java.util.concurrent.*; public class GFG { public static void main(String[] args) { // create an ConcurrentLinkedQueue ConcurrentLinkedQueue<Integer> queue = new ConcurrentLinkedQueue<Integer>(); // Add Numbers to queue queue.add(4353); queue.add(7824); queue.add(78249); queue.add(8724); // Displaying the existing ConcurrentLinkedQueue System.out.println("ConcurrentLinkedQueue: " + queue); // check whether queue contains 78249 boolean response1 = queue.contains(78249); // print after applying contains method System.out.println("queue contains Number 78249 : " + response1); // check whether queue contains 9876 boolean response2 = queue.contains(9876); // print after applying contains method System.out.println("queue contains Number 9876: " + response2); } } Output: ConcurrentLinkedQueue: [4353, 7824, 78249, 8724] queue contains Number 78249 : true queue contains Number 9876: false Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentLinkedQueue.html#contains-java.lang.Object- Comment More infoAdvertise with us Next Article ConcurrentLinkedQueue contains() method in Java A AmanSingh2210 Follow Improve Article Tags : Java Java-Collections Java - util package java-basics Java-Functions Java-ConcurrentLinkedQueue +2 More Practice Tags : JavaJava-Collections Similar Reads 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 isEmpty() method in Java The isEmpty() method of ConcurrentLinkedQueue is used to check if this queue is empty or not. It returns true if ConcurrentLinkedQueue contains zero number of elements means if the ConcurrentLinkedQueue is empty. Syntax: public boolean isEmpty() Returns: This method returns true if this ConcurrentLi 2 min read ConcurrentLinkedDeque contains() method in Java with Examples 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 2 min read ConcurrentLinkedQueue offer() method in Java The offer() method of ConcurrentLinkedQueue is used to insert the element, passed as parameter, at the tail of this ConcurrentLinkedQueue. This method returns True if insertion is successful. ConcurrentLinkedQueue is unbounded, so this method offer() will never returns false. Syntax: public boolean 2 min read ConcurrentSkipListSet contains() method in Java The contains() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns a true boolean value if the specified element is present in this set otherwise it returns false. Syntax: ConcurrentSkipListSet.contains(Object o) Parameters: The function accepts a singl 2 min read Like