The Comparable interface is used by the Collection.sort() method and the java.util.Array.sort() method to sort Lists and array of objects, respectively. To implement Comparable, a class must implement a single method, compareTo(). Read the rest of this entry »
EnumMap is specialized Map implementation designed and optimized for using Java Enum as key. EnumMap in Java is added on JDK 5 release. There are some similarities as well as differences between EnumMap and HashMap which you can find here. Followings are the features of EnumMap. Read the rest of this entry »
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.
- It contains only unique elements.
- It can’t have null key but can have multiple null values.
- It is not synchronized i.e not safe for multi-threaded application.
- It is same as HashMap instead maintains ascending order.