TreeMap in Java

TreeMap in Java

The TreeMap class implements the Map interface which store key-value pairs in tree data structure. It provides an efficient means of storing key/values pairs in sorted order.

Followings are the features of TreeMap.

  1. It contains only unique elements.
  2. It can’t have null key but can have multiple null values.
  3. It is not synchronized i.e not safe for multi-threaded application.
  4. It is same as HashMap instead maintains ascending order.

TreeMap provides following constructors.

[table “” not found /]

Example of TreeMap


Leave a Reply

Your email address will not be published. Required fields are marked *