If an implementation is not provided, the compiler will generate a hashCode() method that considers all primary constructor properties in its comparison. The following code shows the hashCode() implementation of our Article class example:
public final class Article {
...
public int hashCode() {
String var10000 = this.title;
int var1 = (var10000 != null ? var10000.hashCode() : 0) * 31;
String var10001 = this.author;
return var1 + (var10001 != null ? var10001.hashCode() : 0);
}
}
Once again, we can see that the implementation only takes into account primary constructor properties in its implementation of hashCode().