I do not understand what two instances of PhoneNumber he is talking about.
The first is the one you used to insert.
m.put(new PhoneNumber(707, 867, 5309), "Jenny"));
The second instance is the one used for extraction.
m.get(new PhoneNumber(707, 867, 5309));
Also, I'm looking again for this object, which should return the same hash code, even if it inherits the hashCode method from the object class.
This is not true. By default, the implementation of the hashCode() class in Object returns separate integers for different objects, because it is implemented by converting the internal address of the object to an integer. Therefore, hash verification is not performed.
If, on the other hand, you tried to retrieve PhoneNumber using the same instance
PhoneNumber phoneNum = new PhoneNumber(707, 867, 5309); m.put(phoneNum, "Jenny")); m.get(phoneNum);
Checking the hash code will pass (since you used the same object that was inserted before) and equals() . This, of course, is not recommended, because we are much more likely to use a different key object than the one used for insertion.
The key used, however, will have a meaningful equivalent (for example, another String object, but whose text is the same), and therefore, the implementation of hashCode() necessary for proper matching and searching.
Also see: Checking and deleting elements in Java HashMap