Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsUnmodifiableNavigableMapExample1 { public static void main(String[] args) { //Create object of hash map and Add values in the map NavigableMap
map = new TreeMap
(); map.put("key1", "Java"); map.put("key2", "Android"); map.put("key3", "JavaScript"); System.out.println("Initial Map: "+map); //Create unmodifiable navigable map NavigableMap
map2 = Collections.unmodifiableNavigableMap(map); System.out.println("Unmodifiable Navigable Map: " + map2); map.put("key4", "JavaTpoint"); System.out.println("Unmodifiable Navigable Map after adding: " + map2); } }
Output