What is Map and SortedMap interface? - Map is used to store the key-Value pairs.
Map interfaces - Map implemented by HashMap and TreeMap. - SortedMap implemented by TreeMap. Explain the concepts of Map and SortedMap interface. Keys will be mapped to their values using Map object. Map allows no duplicate values. The keys in a map objects must be unique. Java collection framework allows implementing Map interface in three classes namely, HashMap, TreeMap and LinkedHashMap.
SortedMap is a special interface for maintaining all the elements in a sorted order. This interface extends Map interface. It maintains all the elements in ascending order. The sorting process is performed on the map keys. It has two additional methods than Map interface. They are firstKey() and lastKey(). Method firstKey() returns the first value available currently in the map, where as the lastKey() returns the last value available currently in the map.
|