Set isEmpty() method in Java with Examples Last Updated : 31 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The java.util.Set.isEmpty() method is used to check if a Set is empty or not. It returns True if the Set is empty otherwise it returns False. Syntax: boolean isEmpty() Parameters: This method does not take any parameter Return Value: The method returns True if the set is empty else returns False. Below program illustrate the java.util.Set.isEmpty() method: Java // Java code to illustrate isEmpty() import java.io.*; import java.util.*; public class SetDemo { public static void main(String args[]) { // Creating an empty Set Set<String> set = new HashSet<String>(); // Use add() method to add elements into the Set set.add("Welcome"); set.add("To"); set.add("Geeks"); set.add("4"); set.add("Geeks"); // Displaying the Set System.out.println("Set: " + set); // Check for the empty set System.out.println("Is the set empty? " + set.isEmpty()); // Clearing the set using clear() method set.clear(); // Again Checking for the empty set System.out.println("Is the set empty? " + set.isEmpty()); } } Output: Set: [4, Geeks, Welcome, To] Is the set empty? false Is the set empty? true Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Set.html#isEmpty() Comment More infoAdvertise with us Next Article Stack isEmpty() method in Java with Example G gopaldave Follow Improve Article Tags : Java Java-Collections Java-Functions java-set Practice Tags : JavaJava-Collections Similar Reads Stack isEmpty() method in Java with Example The Java.util.Stack.isEmpty() method in Java is used to check and verify if a Stack is empty or not. It returns True if the Stack is empty else it returns False. Syntax: Stack.isEmpty() Parameters: This method does not take any parameter. Return Value: This function returns True if the Stackis empty 2 min read SortedSet isEmpty() method in Java with Examples The java.util.SortedSet.isEmpty() method is used to check if a SortedSet is empty or not. It returns True if the SortedSet is empty otherwise it returns False. Syntax: boolean isEmpty() Parameters: This method does not take any parameter. Return Value: The method returns True if the SortedSet is emp 1 min read SortedMap isEmpty() method in Java with Examples The isEmpty() method of SortedMap interface in Java is used to check if a map is having any entry for key and value pairs. If no mapping exists, then this returns true. Syntax: boolean isEmpty() Parameters: This method has no argument. Returns: This method returns True if the map does not contain an 2 min read Properties isEmpty() method in Java with Examples The isEmpty() method of Properties class is used to check if this Properties object is empty or not. Syntax: public boolean isEmpty() Parameters: This method accepts no parameters Returns: This method returns a boolean value stating if this Properties object is empty or not. Below programs show the 2 min read Map isEmpty() Method in Java with Examples This method is used to check if a map is having any entry for key and value pairs. If no mapping exists, then this returns true. Syntax: boolean isEmpty() Parameters: This method has no argument. Returns: This method returns True if the map does not contain any key-value mapping. Below programs show 1 min read List isEmpty() method in Java with Examples The isEmpty() method of the List interface in Java is used to check if a list is empty or not. It returns true if the list contains no elements otherwise it returns false if the list contains any element.Example:Java// Java Progrm to Implement // List isEmpty() Method import java.util.*; class Main 2 min read Like