This is a function that returns an integer corresponding to the hashcode generated by hashing algorithms of Java Objects.

  • By default returns the classes’ address
  • Valid implementations of hashcode follow that whenever Java .equals() is true it implies that the hashcodes of the objects must be true aswell. Custom hashing algorithms must be created for custom classes.

Example Hashing Algorithm

@Override
public int hashCode() {
    int hash = 7;
    hash = 31 * hash + (int) id;
    hash = 31 * hash + (name == null ? 0 : name.hashCode());
    hash = 31 * hash + (email == null ? 0 : email.hashCode());
    return hash;
}