The difference between HashSet and TreeSet

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.
This link: https://blog.csdn.net/weixin_45151960/article/details/102756580

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.

Guess you like

Origin blog.csdn.net/weixin_45151960/article/details/102756580