Online Java Compiler By
JavaTpoint.com
package myPackage; import java.util.*; public class CollectionsCheckedNavigableMapExample3 { public static void main(String[] args) { NavigableMap
hmap = new TreeMap<>(); //Insert values in the Map hmap.put("A", 11); hmap.put("B", 12); hmap.put("C", 13); hmap.put("V", 14); System.out.println("Type safe view of the Navigable Map1 is: "+Collections.checkedNavigableMap(hmap,String.class,Integer.class)); NavigableMap
hashmap = new TreeMap<>(); hashmap.put(11, "A"); hashmap.put(12, "B"); hashmap.put(11, "A"); hashmap.put(12, "B"); //Create type safe view of the Map System.out.println("Type safe view of the Navigable Map2 is: "+Collections.checkedNavigableMap(hashmap,Integer.class,String.class)); } }
Output