Java TreeMap putAll(Map map) Method

The put(K key, V value) method of java.util.TreeMap class associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced whereas putAll(Map<? extends K,? extends V> map) copies all of the mappings from the specified map to this map. These mappings replace any mappings that this map had for any of the keys currently in the specified map.
[Read more…]

Java TreeMap navigableKeySet() Method Example

The descendingKeySet() method of java.util.TreeMap class returns a reverse order NavigableSet view of the keys contained in this map. The set’s iterator returns the keys in descending order whereas navigableKeySet() returns a NavigableSet view of the keys contained in this map. The set’s iterator returns the keys in ascending order. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa.
[Read more…]