The hash table cannot use mutable objects as the key value, that is, the content of the reference type cannot be mutable, which is unsafe, because the hashcode function calculates the position of the key and value according to the content of the object, if the content of the referenceIf it is variable, the result of each search will be different, and the previously stored key-value pairs will not be found, which does not conform to the design principles of hash. For example, the list type is variable, and the tuple is immutable
The hash table inserts and deletes elements as shown in the figure above, and the output is as follows:
set:
The bottom layer of set is a specialThe value of the hashmap corresponds to the key in the key-value pair, so it cannot store mutable objects.
The establishment of set needs to be passed in in the form of a list, and can also be added directly through the add method:
Result:
Wanyeji Faint thunder , Cloud
List of articles 1. Friends pr