TreeMap in Java

What is TreeMap It is a Red-Black tree based NavigableMap implementation. Like HashMap it contains only unique elements. Unlike HashMap it cannot have null key but like HashMap it can have multiple null values. The map is sorted according to the natural ordering (ascending order) of its keys, or by a Comparator provided at map […]

Read More

LinkedHashMap in Java

What is LinkedHashMap A LinkedHashMap like HashMap is a simple yet powerful way to store and get data. Unlike HashMap, LinkedHashMap is based on HashTable and Linked list implementation of the Map interface and stores items as key/value pairs. Like HashMap, LinkedHashMap permits only unique keys. It also permits only one null key (whereas HashTable […]

Read More

HashMap in Java

What is HashMap A HashMap is a simple yet powerful way to store and get data. HashMap is based on HashTable implementation, that implements the Map interface and stores items as key/value pairs. HashMap permits only unique keys. It also permits only one null key (whereas HashTable does not allow any null key) but may […]

Read More

ConcurrentHashMap in Java

Though we have thread-safe collections classes like HashTable, Synchronized Map, which can be used in multi-threaded environment but there are significant differences between them, which arise from the fact that how they achieve their thread-safety. All methods of Hashtable are synchronized which make them quite slow due to the number of thread increases. Synchronized Map […]

Read More