Right, hashCode two objects (the) same, equals () is not necessarily true.
Code Example:
1 String str1 = "通话"; 2 String str2 = "重地"; 3 System.out.println(String.format("str1:%d | str2:%d", str1.hashCode(),str2.hashCode())); 4 System.out.println(str1.equals(str2));
Results of the:
str1:1179395 | str2:1179395
false
Code Interpretation: It is clear that "talk" and "heavy" in hashCode () the same, however, equals () was true, because in the hash table, hashCode () that is equal to two hash values of key-value pairs are equal, however, equal hash value, not necessarily produce the key-value pairs are equal.