Java tutorial
import java.util.Collections; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; public class Main { public static void main(String[] s) { // create sorted map SortedMap<String, String> map = new TreeMap<String, String>(); // populate the set map.put("1", "New"); map.put("2", "to"); map.put("3", "java2s.com"); System.out.println("Initial sorted map value: " + map); // create unmodifiable sorted map Map<String, String> unmodsortmap = Collections.unmodifiableSortedMap(map); // try to modify the sorted map unmodsortmap.put("4", "Modify"); } }