31 May 2024

#Map_interface

#Map_interface
TreeMap
  • It contains values based on the key. It implements the NavigableMap interface and extends AbstractMap class.
  • It contains only unique elements.
  • It cannot have a null key but can have multiple null values.
  • It is non synchronized.
  • It maintains ascending order.
HashMap
  • It contains values based on the key.
  • It contains only unique keys.
  • It may have one null key and multiple null values.
  • It is non synchronized.
  • It maintains no order.
  • The initial default capacity of Java HashMap class is 16 with a load factor of 0.75.
Hashtable
  • A Hashtable is an array of a list. Each list is known as a bucket. The position of the bucket is identified by calling the hashcode() method. A Hashtable contains values based on the key.
  • Java Hashtable class contains unique elements.
  • Java Hashtable class doesn't allow null key or value.
  • Java Hashtable class is synchronized.
  • The initial default capacity of Hashtable class is 11 whereas loadFactor is 0.75.
ConCurrentHashmap

No comments:

Post a Comment

Most views on this month