Java Collections checkedNavigableMap() Method with Examples Last Updated : 18 Jan, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report The checkedNavigableMap() method of Java Collections is a method that returns a dynamically and typesafe view of the given Map. Any attempt to insert an element of the wrong type will result in an immediate ClassCastException. Syntax: public static <Key,Value> NavigableMap<Key,Value> checkedNavigableMap(NavigableMap<Key,Value> Map, Class<Key> keyType, Class<V> valueType) Parameters: Key is the KeyValue is the ValueMap is the input mapkeyType is the data type of the keyvalueType is the data type of the value Return: This method will return the dynamically and typesafe view of the given Map. Exceptions: ClassCastException: ClassCastException is a runtime exception raised in Java when we improperly cast a class from one type to another. Example: Java // Java program to create typesafe // view from the map import java.util.*; public class GFG { // main method public static void main(String[] args) { // createa tree map NavigableMap<String, Integer> data = new TreeMap<>(); // Insert values in the given map data.put("id1", 56); data.put("id2", 15); data.put("id3", 19); data.put("id4", 70); // Create type safe view of the given Map System.out.println(Collections.checkedNavigableMap( data, String.class, Integer.class)); } } Output{id1=56, id2=15, id3=19, id4=70} Example 2: Java // Java program to create // typesafe view from the map import java.util.*; public class GFG { // main method public static void main(String[] args) { // createa tree map NavigableMap<String, String> data = new TreeMap<>(); // Insert values in the given map data.put("id1", "sravan"); data.put("id2", "manoj"); data.put("id3", "sai"); data.put("id4", "vignesh"); // Create type safe view of the given Map System.out.println(Collections.checkedNavigableMap( data, String.class, String.class)); } } Output{id1=sravan, id2=manoj, id3=sai, id4=vignesh} Comment More infoAdvertise with us Next Article Collections checkedSortedMap() method in Java with Examples M manojkumarreddymallidi Follow Improve Article Tags : Java Java-Functions Java-Collections-Class Practice Tags : Java Similar Reads Java Collections checkedNavigableSet() Method with Examples The checkedQueue() method of Java Collections is a method that returns a dynamically and typesafe view of the given Set. Any attempt to insert an element of the wrong type will result in an immediate ClassCastException. Syntax: public static <E> NavigableSet<E> checkedNavigableSet(Naviga 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 Collections checkedSortedMap() method in Java with Examples The checkedSortedMap() method of java.util.Collections class is used to return a dynamically typesafe view of the specified sorted 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 returned map permits ins 2 min read Collections checkedList() method in Java with Examples The checkedList() method of Collections class is present inside java.util package is used to return a dynamically typesafe view of the specified list. The key thing to note here is that the returned list will be serializable if the specified list is serializable. Since null is considered to be a val 3 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 ConcurrentSkipListMap containsKey() method in Java with Examples The containsKey() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which returns a true boolean value if the specified element is present in this map otherwise it returns false. Syntax: public boolean containsKey(Object ob) Parameter: The function accepts a single 2 min read Like