SortedMap isEmpty() method in Java with Examples Last Updated : 21 Jan, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 any key-value mapping. Note: The isEmpty() method in SortedMap is inherited from the Map interface in Java Below programs show the implementation of int isEmpty() method: Program 1: Java // Java code to show the implementation of // isEmpty method in SortedMap interface import java.util.*; public class GfG { // Driver code public static void main(String[] args) { // Initializing a SortedMap SortedMap<String, String> map = new TreeMap<>(); System.out.println(map); System.out.println(map.isEmpty()); } } Output: {} true Program 2: Below is the code to show the implementation of isEmpty(). Java // Java code to show the implementation of // isEmpty method in SortedMap interface import java.util.*; public class GfG { // Driver code public static void main(String[] args) { // Initializing a SortedMap SortedMap<String, String> map = new TreeMap<>(); map.put("1", "One"); map.put("3", "Three"); map.put("5", "Five"); map.put("7", "Seven"); map.put("9", "Ninde"); System.out.println(map); System.out.println(map.isEmpty()); } } Output: {1=One, 3=Three, 5=Five, 7=Seven, 9=Ninde} false Reference: https://docs.oracle.com/javase/6/docs/api/java/util/ArrayList.html#contains(java.lang.Object) Comment More infoAdvertise with us Next Article SortedSet isEmpty() method in Java with Examples G gopaldave Follow Improve Article Tags : Java Java - util package Java-Functions Java-SortedMap Practice Tags : Java Similar Reads 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 Set isEmpty() method in Java with Examples 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. Be 1 min read 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 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 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 SortedMap put() method in Java with Examples The put() method of SortedMap interface in Java is used to associate the specified value with the specified key in this map. Syntax: V put(K key, V value) Parameters: This method has two arguments: key: which is the left argument and value: which is the corresponding value of the key in the map. Ret 2 min read Like