I noticed in examples of hashCode(), everyone is using the same fields to call hashCode() inside the hashCode() method definition.
Why should I have to call/initialize the hashCode() method for each member of a class, as hash code is for the finding the object location (correct me if i am wrong)?
So what is the purpose of calling the hashCode() inside the hashCode() method definition.
For example:
public int hashCode() {
final int seed = 37;
int result = 1;
result = seed * result + ((name == null) ? 0 : name.hashCode());
result = seed * result + age;
result = seed * result + marks;
return result;
}
Here we have two fields age and name. What is the purpose of name.hashCode() on line no 4.