ConcurrentSkipListSet contains() method in Java Last Updated : 17 Sep, 2018 Comments Improve Suggest changes Like Article Like Report 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 single parameter o i.e. to be checked for the presence in this set. Return Value: The function returns a Boolean value. It returns True if the specified element is present in this set else it returns False. Below programs illustrate the ConcurrentSkipListSet.contains() method: Program 1: Java // Java Program Demonstrate contains() // method of ConcurrentSkipListSet import java.util.concurrent.*; class ConcurrentSkipListSetContainsExample1 { public static void main(String[] args) { // Initializing the set ConcurrentSkipListSet<Integer> set = new ConcurrentSkipListSet<Integer>(); // Adding elements to this set for (int i = 10; i <= 15; i++) set.add(i); // Checks if 9 is present in the set if (set.contains(9)) System.out.println("9 is present in the set."); else System.out.println("9 is not present in the set."); } } Output: 9 is not present in the set. Program 2: Java // Java Program Demonstrate contains() // method of ConcurrentSkipListSet */ import java.util.concurrent.*; class ConcurrentSkipListSetContainsExample2 { public static void main(String[] args) { // Initializing the set ConcurrentSkipListSet<String> set = new ConcurrentSkipListSet<String>(); // Adding elements to this set set.add("Gfg"); set.add("is"); set.add("fun"); // Checks if Gfg is present in the set if (set.contains("Gfg")) System.out.println("Gfg is present in the set."); else System.out.println("Gfg is not present in the set."); } } Output: Gfg is present in the set. Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListSet.html#contains-java.lang.Object- Create Quiz Comment R rupesh_rao Follow 0 Improve R rupesh_rao Follow 0 Improve Article Tags : Java Java-Collections Java - util package Java-Functions Java-ConcurrentSkipListSet +1 More Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings7 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java5 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages2 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java4 min readJava Comparator Interface5 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java7 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management3 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like