HashSet is implemented by a hash table. The data in HashSet is unordered and can be put in null, but only one null can be put in. The values in both cannot be repeated, just like the unique constraint in the database
TreeSet is implemented by binary difference tree. The data in Treeset is automatically sorted, and null values are not allowed.
The above statement shows that HashSet or TreeSet can be used when it is necessary to filter repeated characters or numbers, and the latter can be sorted at the same time.