Java TreeMap class is used to store items in the form of <key, value> pair. The TreeMap class in java is part of the  Java Collection framework. It extends the AbstractMap class and implements the NavigableMap interface. It is non-synchronized therefore it is not suitable to use it in  multithreaded applications.

TreeMap in Java

The elements stored in the TreeMap are sorted according to the natural ordering of the keys by default. The elements stored in TreeMap are unique. It can have multiple null values, but it does not allow a null key.

The internal structure of a TreeMap contains three variables, that is Object keyObject value and boolean color (as TreeMap is based on a red-black tree). It also contains three references that are left, right and parent.

#java #treemap #abstractmap #navigablemap

TreeMap in Java Example | Java TreeMap Tutorial
1.60 GEEK