Introduction Java HashSet

Implemented using the underlying HashSet HashMap. When adding objects to Set them using the add method, in fact, it is the object as a Map object underlying the maintenance of the key, and the value is the same Object object (which we do not have access).

1, HashSet constructor

 

2, HashSet add method,

 Which is a fake object PRESENT

    // Dummy value to associate with an Object in the backing Map
    private static final Object PRESENT = new Object();

  

Guess you like

Origin www.cnblogs.com/linlf03/p/10961171.html