Skip to content
- The underlying data structure is red-black tree
- Insertion Order is not preserved
- All elements inserted in the sorting order of keys
- Duplicate keys are not allowed
- Duplicates values are allowed
- Homogeneous objects are allowed which implement comparable interface (Else class cast exception)
- If we are implementing the comparator interface then objects need not be homogeneous or implement comparable interface
- Wheather we are dependent on default natural sorting order or customized sorting order there are no restrictions for values.
- Null keys not allowed in TreeMap
Constructers
- Map m = new TreeMap()
- Map m = new TreeMap(Comparator c)
- Map m = new TreeMap(SortedMap s)
- Map m = new TreeMap(Collection c)
Example