Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
The difference between HashSet and TreeSet
- HashSet
The interior is by a hash table (actually a HashMap instance) support. It is not guaranteed iteration order of the set element.
- TreeSet
TreeSet uses natural ordering sorts the elements of the element, or sorted according to a Comparator provided when creating the set.