Java Collections unmodifiableSortedMap() MethodThe unmodifiableSortedMap() method of Java Collections class is used to get an unmodifiable view of the specified sorted map. SyntaxFollowing is the declaration of unmodifiableSortedMap() method: Parameter
ReturnsThe unmodifiableSortedMap() method returns an unmodifiable view of the specified sorted map. ExceptionsNA Example 1Test it NowOutput: Original Map: {1=1001, 2=1002, 3=1003, 4=1004} Unmodifiable Sorted Map: {1=1001, 2=1002, 3=1003, 4=1004, 5=1005} Example 2Test it NowOutput: Original Map: {1=Whatsapp, 2=Twitter, 3=Facebook, 4=Instagram} Unmodifiable Sorted Map: {1=Whatsapp, 2=Twitter, 3=Facebook, 4=Instagram, 5=Hangout} Example 3Test it NowOutput: Original Map: {1=one, 2=two} Exception in thread "main" java.lang.UnsupportedOperationException at java.base/java.util.Collections$UnmodifiableMap.remove(Collections.java:1456) at myPackage.CollectionsUnmodifiableSortedMapExample3.main(CollectionsUnmodifiableSortedMapExample3.java:10) 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