Set isEmpty() method in Java with Examples Last Updated : 31 Dec, 2018 Comments Improve Suggest changes 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 Set isEmpty() method in Java with Examples 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 Java String isEmpty() Method with Example In Java, the String isEmpty() method checks if a string is empty (length is zero). This method returns true if the string is empty and false otherwise. It is useful for validating strings in our applications.In this article, we will learn how to use the isEmpty() method in Java along with examples t 3 min read WeakHashMap isEmpty() Method in Java with Examples The java.util.WeakHashMap.isEmpty() method of HashMap class is used to check for the emptiness of the map. The method returns True if no key-value pair or mapping is present in the map else False. Syntax: Weak_Hash_Map.isEmpty() Parameters: The method does not take any parameters. Return Value: The 2 min read Field set() method in Java with Examples The set() method of java.lang.reflect.Field is used to set the value of the field represented by this Field object on the specified object argument to the specified new value passed as parameter. The new value is automatically unwrapped if the underlying field has a primitive type. If the field is s 4 min read ArrayList isEmpty() Method in Java with Examples In Java, the isEmpty() method of ArrayList is used to check if an ArrayList is empty.Example 1: Here, we use the isEmpty() method to check whether an ArrayList of integers is empty.Java// Java program to demonstrate the use of isEmpty() // method with ArrayList of Integers import java.util.ArrayList 2 min read Like