Skip to content

Glossary: Algorithms Beyond the Basics in Java

identity vs equals

Also written: arrays compare by identity, equals, hashCode

Arrays are equal as map keys only if they are the very same object, so a fresh `int[]` with the same numbers is a different key. Records and Lists compare by contents, so use them as multi-part keys.

Where the book teaches it

Related terms

recordmemoization