Difference between HashMap and TreeMap?



HashMap

  • HashMap is unordered 
  •  HashMap allows null keys. 
  •  HashMap allows different type of keys.    

TreeMap

  •     TreeMap elements are in sorted ordered in term of keys. 
  •     TreeMap doesn’t allow null keys.
  •     TreeMap allows only similar types of keys