Java
You're viewing a free preview. Sign in free to read every script.
Why this exists Every Java object inherits three methods from Object: equals, hashCode and toString. Their defaults compare identity (are these the very same object in memory?) and print something like Host@1b6d3586.…
Java Basics: equals, hashCode, toString, Sorting and Immutable Objects
Why two identical-looking objects are not equal by default, how equals and hashCode must agree for HashSet and HashMap to work, the mutable-key trap, records as the shortcut, Comparator sorting, and building immutable objects with defensive copies.
Sign in free to read this script, along with the rest of the library.
Sign in free