I was learning hashcode in more depth and figured that:
1. If you override equals(), you must override hashcode() too.
2. To find if
==
is identity.
.equals()
is equality.
.equals()
defaults to just using ==
(just like hashCode()
defaults to System.identityHashCode()
but you can override them if there's a more meaningful way to check for equality. Typically this is a sort of "structural" equality. ie: are all of the pieces of this
.equal()
to all of the pieces of that
?