InterviewSolution
Saved Bookmarks
| 1. |
HashSet vs TreeSet in Java |
||||||||||||||||||||||||
|
Answer» The HashSet class implements the Set interface, supported by a Hashtable. Due to the implementation of the Set Interface, duplicate VALUES are not ALLOWED. The underlying data structure for a HashSet is a Hashtable. The TREESET class implements the SortedSet interface, which in turn extends the Set interface. Objects are stored in a sorted ascending order. The underlying data structure for TreeSet is a tree. Here are a few notable differences between a HashSet and a TreeSet:
|
|||||||||||||||||||||||||