Hash hash,
When adding objects, first determine whether the hashcode of two objects is the same, if different, directly add, if the same, then judge the Equals method, if different directly add Equls the main function is to compare the contents of the object. If it is different, it can be added regardless of whether it is the same object.
Equals is to determine whether the object content is equal
Hashcode
HashSet HashMap can not store duplicate elements, judge the standard.
Judge Hashcode and judge the Equals method first.
Hashcode can be added directly, even if the same object can be added.
The second condition is the Equals method, and the return value is a Boolean value. Determines whether the value of the object is the same.
The advantage is the speed of the retrieval.
HashSet: Thread insecure, fast access speed, how unique it is.
TreeSet: Thread is unsafe, you can sort the elements in the set collection.
Element uniqueness is ensured through the CompareTo Comapre method.
Features of generics:
Map collection is different from collection? Parallel presence
Map fastidious is kv to key-value---->entry (entry)
Key (Key)--value (value)
Map.put collection is using the add
The map element does not have a way to take the element directly, and it is first converted to set and then taken out of the iteration to fetch the corresponding value.
All keys are in a set, and the values in the set cannot be duplicated.
The set Set=map.keyset () return value must be a collection.
Map.get (key) Gets the value in the map.
The uniqueness of the elements is guaranteed in the Map collection.
Java Foundation 11th Day Summary