Java Collections unmodifiableSortedMap() Method21 Mar 2025 | 2 min read The 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 1Output: Original Map: {1=1001, 2=1002, 3=1003, 4=1004} Unmodifiable Sorted Map: {1=1001, 2=1002, 3=1003, 4=1004, 5=1005} Example 2Output: Original Map: {1=Whatsapp, 2=Twitter, 3=Facebook, 4=Instagram} Unmodifiable Sorted Map: {1=Whatsapp, 2=Twitter, 3=Facebook, 4=Instagram, 5=Hangout} Example 3Output: 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 |
Java Collections Method The is an inbuilt method of Java Collections class. This method is used to get a dynamically typesafe view of the specified sorted set. Syntax Following is the declaration of method: public static <E> SortedSet<E> checkedSortedSet(SortedSet<E> s, Class<E> type) Parameter Parameter Description Required/Optional s It is the sorted set...
2 min read
Java Collections Method The method of Java Collections class is used to get the empty navigable Set which is immutable in nature. Syntax Following is the declaration of method: public static <E> NavigableSet<E> Parameter This method does not accept...
2 min read
Java Collections. Method The method of Java Collections class is used to get the Set that has no elements. These empty Set are immutable in nature. Syntax Following is the declaration of method: public static final <T> Set<T> Parameter This method does not accept any parameter. Returns The ...
5 min read
Java Collections Method The is a method of Java Collections class which returns a dynamically typesafe view of the specified Queue. If an element inserted of the wrong type, it will result in an immediate ClassCastException. Syntax Following is the declaration of method: public static <E>...
2 min read
Java Collections Method The method of Java Collections class is used to get a List that has no elements. These empty list are immutable in nature. The Collections. method in Java, part of the java.util.Collections class, returns an immutable empty List. This means that the...
5 min read
Java Collections Method The heckedNavigableMap() is an inbuilt method of Java Collections class. This method is used to get a dynamically typesafe view of the specified Navigable Map. If there is any attempt of insert mapping whose key or value has the wrong type, it...
3 min read
Java Collections Method The method of Java Collections class is used to get an unmodifiable view of the specified collection. If any attempt occurs to modify the returned collection whether direct or via its iterator, result in an UnsupportedOperationException. Syntax Following is the declaration of ...
2 min read
Java Collections Method The method of Java Collections class is used to get a List Iterator that has no elements. Syntax Following is the declaration of method: public static <T> ListIterator<T> Parameter This method does not accept any parameter. Returns The method returns the list Iterator that...
2 min read
Java Collections Method The method of Java Collections class is used to get the starting position of the first occurrence of the specified target list within the specified source list. It returns -1 if there is no such occurrence in the specified list. Syntax Following is...
3 min read
Java Collections Method The method of Java Collections class is used to rotate the elements in the specified list by a given distance. Syntax Following is the declaration of method: public static void rotate(List<?> list, int distance) Parameter Parameter Description Required/Optional list It is the list which will be rotated. Required distance It is...
3 min read
We request you to subscribe our newsletter for upcoming updates.
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