For:
No, if two objects x and y satisfy x.equals (y) = = True, their hash code (hash code) should be the same. Java for the Eqauls method and Hashcode method is this: (1) If two objects are the same (the Equals method returns True), then their hashcode values must be the same, (2) If two objects have the same hashcode, they are not necessarily the same. Of course, you may not have to do as required, but if you violate the above principles you will find that when using containers, the same objects can appear in the set set, while the efficiency of adding new elements is greatly reduced (for systems using hash storage, if the hash code conflicts frequently, the access performance will be drastically reduced).
Add: About Equals and Hashcode methods, many Java programs are known, but many people just know, in Joshua Bloch's masterpiece "Effective Java" (Many software companies, "effective Java", " Java Programming Ideas and refactoring: Improving existing code quality is the Java programmer must read books, if you have not seen, then quickly go to the Amazon to buy a copy of it is described in this way: first the Equals method must satisfy the reflexivity (x.equals (x) Must return True), symmetry (x.equals (Y) returns True when Y.equals (x) must also return true), transitivity (X.equals (y) and y.equals (z) all return True when X.equals (z) must also return true) and consistency (when the object information referenced by x and Y is not modified, multiple calls to X.equals (y) should get the same return value), and a reference to any non-null value x,x.equals (NULL) must return FALSE. The tips for achieving a high-quality Equals method include: 1. Use the = = operator to check if the parameter is a reference to this object; 2. Use the instanceof operator to check if the parameter is the correct type; 3. For the key properties in the class, check that the properties of the parameter's incoming object match; 4. After writing the Equals method, ask yourself whether it satisfies symmetry, transitivity, consistency; 5. Overriding equals always overrides Hashcode;6. Do not replace object objects in the Equals method argument with other types, and do not forget the @override annotations when overriding.
Two object values are the same (x.equals (y) = = true), but can have different hash code, is that right?