Java Collections emptySortedMap() Method with Examples Last Updated : 03 Jan, 2022 Comments Improve Suggest changes Like Article Like Report The emptySortedMap() method of Java Collections is used to get a map that has no elements. A Sorted map is a data structure that can hold elements with key-value pairs in sorted order. Syntax: public static final <Key,Value> SortedMap<Key,Value> emptySortedMap() where, key is the key elementvalue is the value element Parameters: This method does not take any parameters. Return Type: It will return an empty sorted map that is immutable. Example 1: Java program to create an empty sorted map. Java import java.util.*; public class GFG { // main method public static void main(String[] args) { // create an empty sorted map SortedMap<String, String> data = Collections.emptySortedMap(); // display System.out.println(data); } } Output{} Example 2: In this program, we are going to create an empty sorted map and add elements to the map. This method will return an error. Java import java.util.*; public class GFG { // main method public static void main(String[] args) { // create an empty sorted map SortedMap<String, String> data = Collections.emptySortedMap(); // add 3 elements data.put("1", "ojaswi"); data.put("2", "ramya"); data.put("3", "deepu"); // display System.out.println(data); } } Output: Exception in thread "main" java.lang.UnsupportedOperationException at java.util.Collections$UnmodifiableMap.put(Collections.java:1459) at GFG.main(GFG.java:10) Example 3: Java import java.util.*; public class GFG { // main method public static void main(String[] args) { // create an empty sorted map SortedMap<Integer, Integer> data = Collections.emptySortedMap(); // add 3 elements data.put(1, 34); data.put(2, 45); data.put(3, 56); // display System.out.println(data); } } Output: Exception in thread "main" java.lang.UnsupportedOperationException at java.util.Collections$UnmodifiableMap.put(Collections.java:1459) at GFG.main(GFG.java:10) Comment More infoAdvertise with us Next Article Java Collections emptySortedMap() Method with Examples O ojaswilavu8128 Follow Improve Article Tags : Java Java-Functions Java-Collections-Class Practice Tags : Java Similar Reads Java Collections emptySortedSet() Method with Examples The emptySortedSet() method of Java Collections is used to get the set that has no elements. This method is used in set collection. A set is a data structure that stores unique elements in a sorted manner. Syntax: public static final <T> Set<T> emptySortedSet() Parameters: This will take 1 min read Java Collections emptyMap() Method with Examples The emptyMap() method of Java Collections is a method that is used to return an empty map such that we can not change the data in map IE it is immutable. Syntax: public static final <Key,Value> Map<Key,Value> emptyMap() where, key is the key elementvalue is the value element Parameters: 1 min read Java Collections emptyNavigableMap() Method with Examples The Java Collections emptyNavigableMap() method is used to get a map with no elements. A Navigable map is a data structure that can hold elements with key-value pairs. Syntax: public static final <Key,Value> SortedMap<Key,Value> emptyNavigableMap() where, key is the key elementvalue is t 2 min read Collections checkedSortedMap() method in Java with Examples The checkedSortedMap() method of java.util.Collections class is used to return a dynamically typesafe view of the specified sorted map.The returned map will be serializable if the specified map is serializable.Since null is considered to be a value of any reference type, the returned map permits ins 2 min read Collections checkedMap() method in Java with Examples The checkedMap() method of Collections class been present inside java.util package is used to return a dynamically typesafe view of the specified map. The returned map will be serializable if the specified map is serializable. Since null is considered to be a value of any reference type, the returne 3 min read Like