Javatpoint Logo
Javatpoint Logo

Java Collections emptyNavigableSet() Method

The emptyNavigableSet() method of Java Collections class is used to get the empty navigable Set which is immutable in nature.

Syntax

Following is the declaration of emptyNavigableSet() method:

Parameter

This method does not accept any parameter.

Returns

The emptyNavigableSet() method returns an immutable navigable Set which has no element.

Exceptions

NA

Compatibility Version

Java 1.8 and above

Example 1

Test it Now

Output:

Empty Navigable Set: []

Example 2

Test it Now

Output:

Created empty immutable Navigable Set: []
Exception in thread "main" java.lang.UnsupportedOperationException
	at java.base/java.util.Collections$UnmodifiableCollection.add(Collections.java:1056)
	at myPackage.CollectionsEmptyNavigableSetExample2.main(CollectionsEmptyNavigableSetExample2.java:9)

Example 3

Test it Now

Output:

Exception in thread "main" java.lang.UnsupportedOperationException
	at java.base/java.util.Collections$UnmodifiableCollection.add(Collections.java:1056)
	at myPackage.CollectionsEmptyNavigableSetExample3.main(CollectionsEmptyNavigableSetExample3.java:7)





Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA