![]() |
VOOZH | about |
The Java Collections emptyNavigableMap() method is used to get a map with no elements. A Navigable map is a data structure that can hold elements with key-value pairs.
Syntax:
public static final <Key,Value> SortedMap<Key,Value> emptyNavigableMap()
where,
Parameters: This method will take no parameters.
Return Type: It will return an empty Navigable map that is immutable.
Example 1:
{}Example 2: In this program, we will create an empty navigable map and add elements to the map. This will return an error.
Output:
Exception in thread "main" java.lang.UnsupportedOperationException at java.util.Collections$UnmodifiableMap.put(Collections.java:1459) at GFG.main(GFG.java:10)
Example 3:
Output:
Exception in thread "main" java.lang.UnsupportedOperationException at java.util.Collections$UnmodifiableMap.put(Collections.java:1459) at GFG.main(GFG.java:10)