Java Collections unmodifiableNavigableSet() MethodThe unmodifiableNavigableSet() method of Java Collections class is used to get an unmodifiable view of the specified navigable set. SyntaxFollowing is the declaration of unmodifiableNavigableSet() method: Parameter
ReturnsThe unmodifiableNavigableSet() method returns an unmodifiable view of the specified navigable set. ExceptionsNA Compatibility VersionJava 1.8 and above Example 1Test it NowOutput: Initial Set: [1, 2, 3, 4, 5] Unmodifiable Navigable Set: [1, 2, 3, 4, 5] Unmodifiable Navigable Set: [1, 2, 3, 4, 5, 15] Example 2Test it NowOutput: Initial Set: [Facebook, Google, Instagram] Unmodifiable Navigable Set: [Facebook, Google, Instagram] Unmodifiable Navigable Set: [Facebook, Google, Instagram, Twitter] Example 3Test it NowOutput: Original Set: [11, 13, 17] Exception in thread "main" java.lang.UnsupportedOperationException at java.base/java.util.Collections$UnmodifiableCollection.add(Collections.java:1056) at myPackage.CollectionsUnmodifiableNavigableSetExample3.main(CollectionsUnmodifiableNavigableSetExample3.java:9) Next TopicJava Collections Class |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India