WeakHashMap isEmpty() Method in Java with Examples Last Updated : 19 Jul, 2018 Comments Improve Suggest changes Like Article Like Report 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 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 java.util.WeakHashMap.isEmpty() method: Program 1: Mapping String Values to Integer Keys. Java // Java code to illustrate the isEmpty() method import java.util.*; public class Weak_Hash_Map_Demo { public static void main(String[] args) { // Creating an empty WeakHashMap Map<String, Integer> weak_hash = new WeakHashMap<String, Integer>(); // Mapping int values to string keys weak_hash.put("Geeks", 10); weak_hash.put("4", 15); weak_hash.put("Geeks", 20); weak_hash.put("Welcomes", 25); weak_hash.put("You", 30); // Displaying the WeakHashMap System.out.println("The Mappings are: "+ weak_hash); // Checking for the emptiness of Map System.out.println("Is the map empty? "+ weak_hash.isEmpty()); } } Output: The Mappings are: {Welcomes=25, 4=15, You=30, Geeks=20} Is the map empty? false Program 2: For an empty WeakHashMap Java // Java code to illustrate the isEmpty() method import java.util.*; public class Weak_Hash_Map_Demo { public static void main(String[] args) { // Creating an empty WeakHashMap Map<String, Integer> weak_hash = new WeakHashMap<String, Integer>(); // Displaying the WeakHashMap System.out.println("The Mappings are: "+ weak_hash); // Checking for the emptiness of Map System.out.println("Is the map empty? "+ weak_hash.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. All methods of Java.util.WeakHashmap Class Comment More infoAdvertise with us Next Article WeakHashMap isEmpty() Method in Java with Examples chinmoy lenka Follow Improve Article Tags : Misc Java Java - util package Java-Functions Java-WeakHashMap +1 More Practice Tags : JavaMisc Similar Reads 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 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 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 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 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 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 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