Map isEmpty() Method in Java with Examples Last Updated : 02 Jan, 2019 Comments Improve Suggest changes Like Article Like Report 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 the implementation of int isEmpty() method. Program 1: Java // Java code to show the implementation of // isEmpty method in Map interface import java.util.*; public class GfG { // Driver code public static void main(String[] args) { // Initializing a Map of type HashMap Map<String, String> map = new HashMap<>(); System.out.println(map); System.out.println(map.isEmpty()); } } Output: {} true Program 2: Below is the code to show implementation of hashCode(). Java // Java code to show the implementation of // isEmpty method in Map interface import java.util.*; public class GfG { // Driver code public static void main(String[] args) { // Initializing a Map of type HashMap Map<String, String> map = new HashMap<>(); 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: Oracle Docs Comment More infoAdvertise with us Next Article Map isEmpty() Method in Java with Examples B barykrg Follow Improve Article Tags : Misc Java Java-Collections Java - util package Java-Functions java-map +2 More Practice Tags : JavaJava-CollectionsMisc Similar Reads Map Interface in Java In Java, the Map Interface is part of the java.util package and represents a mapping between a key and a value. The Java Map interface is not a subtype of the Collections interface. So, it behaves differently from the rest of the collection types.Key Features:No Duplicates in Keys: Keys should be un 11 min read Map put() Method in Java with Examples The Map put() method associates the specified value with the specified key in the map. The map put() method is used to insert new key-value pairs inside a map in Java. If the map already contains the mapping for the specified key, the old value is replaced by the new specified value. Example: Java / 3 min read Map remove() Method in Java with Examples The map.remove() method is used to remove the mapping for a key from this map if it is present in the map. Syntax: V remove(Object key)Parameters: This method has the only argument key, whose mapping is to be removed from the map.Returns: This method returns the value to which this map previously as 2 min read Map clear() method in Java with Example The java.util.Map.clear() method in Java is used to clear and remove all of the elements or mappings from a specified Map collection. Syntax: void clear() Parameters: The method does not accept any parameters. Return Value: The method does not return any value. Below programs are used to illustrate 2 min read Map containsKey() method in Java with Examples The java.util.Map.containsKey() method is used to check whether a particular key is being mapped into the Map or not. It takes the key element as a parameter and returns True if that element is mapped in the map. Syntax: boolean containsKey(key_element) Parameters: The method takes just one paramete 2 min read Map containsValue() method in Java with Examples The java.util.Map.containsValue() method is used to check whether a particular value is being mapped by a single or more than one key in the Map. It takes the value as a parameter and returns True if that value is mapped by any of the key in the map. Syntax: boolean containsValue(Object Value) Param 2 min read Map entrySet() method in Java with Examples The java.util.Map.entrySet() method in Java is used to create a set out of the same elements contained in the map. It basically returns a set view of the map or we can create a new set and store the map elements into them. Syntax: map.entrySet() Parameters: The method does not take any parameter. Re 2 min read Java Map equals() Method The equals() method of Map interface in Java is used to check if two maps are equal. Two maps are considered equal if they meet the following conditions. Both maps must have the same size.Both maps must contain identical key-value pairs. (It means every key in one map must be associated with the sam 2 min read Map get() method in Java with Examples The get() method of Map interface in Java is used to retrieve or fetch the value mapped by a particular key mentioned in the parameter. It returns NULL when the map contains no such mapping for the key. So, let us check how to get value from the map in Java. Syntax of get() method in JavathisMap.get 3 min read Java Map hashCode() Method In Java, the hashCode() method is a part of the Object class and is used to generate a hash code value for an object. Example 1: Hash Code for Different ObjectsThe below Java program demonstrates that every object has a unique hashcode. Java// Java program to demonstrates hashCode() // for different 2 min read Like