Previously, we have been systematically learning about lists and maps. Next, we can start learning set. It's a lot easier to learn set after you know it by map. After all, set implementation classes are based on map (HashSet is implemented by HashMap, TreeSet is implemented by TreeMap).
First, let's look at the set schema.
The Set is an interface inherited from the collection. It is a collection that is not allowed to have duplicate elements.
(Abstractset) is an abstract class that inherits from the abstractcollection,abstractcollection implementation of most functions in set, which facilitates the implementation class of set.
Hastset and TreeSet are two implementation classes of set.
HashSet relies on HashMap, which is actually implemented through HashMap. The elements in the hashset are unordered.
TreeSet relies on TreeMap, which is actually implemented through TREEMAP. The elements in the TreeSet are ordered.
Java Collection 15--set schema