Join Examsbook
656 0

Q: How do you decide when to use HashMap and when to use TreeMap ?

  • Show AnswerHide Answer
  • Workspace

Answer :
Explanation :

For inserting, deleting, and locating elements in a Map, the HashMap offers the best alternative. If, however, you need to traverse the keys in a sorted order, then TreeMap is your better alternative. Depending upon the size of your collection, it may be faster to add elements to a HashMap, then convert the map to a TreeMap for sorted key traversal.

Are you sure

  Report Error

Please Enter Message
Error Reported Successfully