Java Collections emptyNavigableMap() Method

The emptyNavigableMap() method of Java Collections class returns an empty navigable map which is immutable.

Syntax

Following is the declaration of emptyNavigableMap() method:

Parameter

This method does not accept any parameter.

Returns

The emptyNavigableMap() method returns an empty immutable Navigable Map.

Exceptions

NA

Compatibility Version

Java 1.8 and above

Example 1

Test it Now

Output:

Created Empty Navigable Map: {}

Example 2

Test it Now

Output:

Created Empty Navigable Map: {}
Exception in thread "main" java.lang.UnsupportedOperationException
	at java.base/java.util.Collections$UnmodifiableMap.put(Collections.java:1453)
	at myPackage.CollectionsEmptyNavigableMapExample2.main(CollectionsEmptyNavigableMapExample2.java:9)

Example 3

Test it Now

Output:

Exception in thread "main" java.lang.UnsupportedOperationException
	at java.base/java.util.Collections$UnmodifiableMap.put(Collections.java:1453)
	at myPackage.CollectionsEmptyNavigableMapExample3.main(CollectionsEmptyNavigableMapExample3.java:7)





Latest Courses