जॉइन Examsbook
1128 0

प्र: How do you decide when to use HashMap and when to use TreeMap ?

  • उत्तर देखेंउत्तर छिपाएं
  • Workspace

उत्तर :
व्याख्या :

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.

क्या आपको यकीन है

  त्रुटि की रिपोर्ट करें

कृपया संदेश दर्ज करें
त्रुटि रिपोर्ट सफलतापूर्वक जमा हुई