Java Collections emptyMap() Method with Examples Last Updated : 03 Jan, 2022 Comments Improve Suggest changes Like Article Like Report 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: This will not accept any parameters, Return Type: This will return an empty map that is immutable. Exceptions: It will not arise any exception. Example 1: Java // Java program to create an empty map import java.util.*; public class GFG { // main method public static void main(String[] args) { // create an empty map Map<String, String> data = Collections.emptyMap(); System.out.println(data); } } Output{} Example 2: Java // Java program to create an // empty map and add elements // We will get an error because // the method will work on only // an empty map import java.util.*; public class GFG { // main method public static void main(String[] args) { // create an empty map Map<String, String> data = Collections.emptyMap(); // add element data.put("1", "python/R"); System.out.println(data); } } Output: Exception in thread "main" java.lang.UnsupportedOperationException at java.util.AbstractMap.put(AbstractMap.java:209) at GFG.main(GFG.java:8) Comment More infoAdvertise with us Next Article Java Collections emptyMap() Method with Examples S sireeshakanneganti112 Follow Improve Article Tags : Java Java-Functions Java-Collections-Class Practice Tags : Java Similar Reads Java Collections emptySortedMap() Method with Examples 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 ele 2 min read Java Collections emptySet() Method with Examples The emptySet() method is used to get the set that has no elements. This method is used in set collection. A set is a data structure that can store unique elements.Syntax:public static final <T> Set<T> emptySet() Parameters: This method will take no parameters.Return Type: It will return 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 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 Map containsKey() method in Java with Examples The java.util.Map.containsKey() method is used to check whether a particular key is being mapped into the Map or not. It takes the key element as a parameter and returns True if that element is mapped in the map. Syntax: boolean containsKey(key_element) Parameters: The method takes just one paramete 2 min read Like