AbstractMap isEmpty() Method in Java with Examples Last Updated : 26 Oct, 2018 Comments Improve Suggest changes Like Article Like Report The AbstractMap.isEmpty() method of AbstractMap 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: AbstractMap.isEmpty() Parameters: The method does not take any parameters. Return Value: The method returns boolean true if the map is empty or does not contain any mapping pairs else boolean false. Below programs illustrates the working of AbstractMap.isEmpty() method: Program 1: Mapping String Values to Integer Keys. Java // Java code to illustrate the isEmpty() method import java.util.*; public class AbstractMap_Demo { public static void main(String[] args) { // Creating an empty AbstractMap AbstractMap<String, Integer> abs_map = new HashMap<String, Integer>(); // Mapping int values to string keys abs_map.put("Geeks", 10); abs_map.put("4", 15); abs_map.put("Geeks", 20); abs_map.put("Welcomes", 25); abs_map.put("You", 30); // Displaying the AbstractMap System.out.println("The Mappings are: " + abs_map); // Checking for the emptiness of Map System.out.println("Is the map empty? " + abs_map.isEmpty()); } } Output: The Mappings are: {4=15, Geeks=20, You=30, Welcomes=25} Is the map empty? false Program 2: For an empty HashMap Java // Java code to illustrate the isEmpty() method import java.util.*; public class Abstract_Map_Demo { public static void main(String[] args) { // Creating an empty AbstractMap AbstractMap<String, Integer> abs_map = new HashMap<String, Integer>(); // Displaying the AbstractMap System.out.println("The Mappings are: " + abs_map); // Checking for the emptiness of Map System.out.println("Is the map empty? " + abs_map.isEmpty()); } } Output: The Mappings are: {} Is the map empty? true Note: The same operation can be performed with any type of Mappings with variation and combination of different data types. Comment More info C chinmoy lenka Follow Improve Article Tags : Misc Java Java-Collections Java - util package Java-Functions Java-AbstractMap +2 More Explore Java BasicsIntroduction to Java4 min readJava Programming Basics9 min readJava Methods7 min readAccess Modifiers in Java6 min readArrays in Java9 min readJava Strings8 min readRegular Expressions in Java7 min readOOP & InterfacesClasses and Objects in Java10 min readAccess Modifiers in Java6 min readJava Constructors10 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface11 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java6 min readIterator in Java5 min readJava Comparator Interface6 min readException HandlingJava Exception Handling8 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 Java10 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking15+ min readJDBC Tutorial5 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples8 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz | Level Up Your Java Skills1 min readTop 50 Java Project Ideas For Beginners and Advanced [Update 2025]15+ min read Like