isEmpty(): This method is available in java.util.HashMap class of Java.
Syntax:
boolean java.util.HashMap.isEmpty()
This method returns true if this map contains no key-value mappings.
Parameters: NA
Returns: true if this map contains no key-value mappings.
Exceptions: NA
Approach
Java
import java.util.HashMap;public class HashMapisEmpty {public static void main(String[] args) {HashMap<String, Integer> hashMap =new HashMap<String, Integer>();hashMap.put("Hello", 1);hashMap.put("World", 2);System.out.println(hashMap.isEmpty());}}
Output:
false
No comments:
Post a Comment