230k views
5 votes
What is the difference between a TreeSet and a TreeMap?

User Toothbrush
by
7.4k points

1 Answer

5 votes

Answer: TreeSet and Treemap has the following differences :-

  • TreeSet is used for the implementation of the Set interface while TreeMap are used for invoking of the interface of the map.
  • Duplicate object values are not present in the TreeSet but TreeMap has the ability to have the duplicate object values.
  • TreeSet comes in the order of sorted objects while TreeMaps have sorted keys.
  • TreeMap has the storage of the single object values while Treemap can store object values as well as keys .

User Velcrow
by
7.7k points