isEmpty(): This method is available in java.util.TreeMap class of Java.
Syntax:
boolean java.util.AbstractMap.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.TreeMap;public class TreeMapisEmpty {public static void main(String[] args) {TreeMap<Integer, String> treeMap =new TreeMap<Integer, String>();treeMap.put(2, "Hello");treeMap.put(11, "Java");treeMap.put(23, "Program");treeMap.put(6, "C++");treeMap.put(25, "Program");System.out.println(treeMap.isEmpty());}}
Output:
false
No comments:
Post a Comment