Introduction of TreeMap:
TreeMap is an implementation of Sorted Map interface. It is dynamically resizable data structure. It contains data in key-value pair where key has to be unique. TreeMap can increase or decrease its size dynamically.
TreeMap is not synchronized. If more than one thread try to access elements in map simulataneously and one of the thread modifies the element, JVM throws concurrentmodification exception. Hence, TreeMap should be synchronized in a multi threaded enviornment.
TreeMap is useful when elements are required in sorted order. Treemap maintains the order based on natural order of the keys or by comparator at creation time.
TreeMap class in JAVA provides following methods:
1. put(Object key, Object value)
2. get(Object key)
5. containsKey(Object key)
6. containsValue(Object value)
More about TreeMap including time complexity is coming very soon.