Collections.emptyMap() has the following syntax.
public static final <K,V> Map <K,V> emptyMap()
In the following code shows how to use Collections.emptyMap() method.
// w w w . j a v a 2 s . com import java.util.Collections; import java.util.Map; public class Main { public static void main(String args[]) { // create an empty map Map emptymap = Collections.emptyMap(); System.out.println("Created empty immutable map: "+emptymap); // try to add elements emptymap.put("1","from java2s.com"); } }
The code above generates the following result.