liveBook · Manning

Equality by value

Equality by value is an equality semantics in which values are considered equal when they represent equivalent contents, regardless of object identity.

How 3 Manning books explain it

100 Java Mistakes and How to Avoid Them

The equals method is the Object method conventionally overridden to determine logical equality between objects.

How it is used
Distinguishes logical object comparison from reference identity before objects enter algorithms and collections.
How deep it goes
Explains call-site traps, type-specific alternatives, implementation mistakes, and hashCode consistency rather than deriving the full equality contract.
Examples
Uses cached Integer values, atomic variables, accidental unrelated arguments, faulty field comparisons, and mutated collection keys.
What you can do after
Diagnose/debug with it by choosing appropriate value comparisons and spotting equality failures in collection behavior.

Read how 100 Java Mistakes and How to Avoid Them explains equality by value →

Java Persistence with Spring Data and Hibernate epub

The equals method is the Java object method that determines whether one object should be considered equal to another.

How it is used
Distinguishes Java object equality from instance identity and database row identity when mapping persistent objects.
How deep it goes
Works through equality overrides, detached-instance behavior, and generated-identifier hash instability; limits the need for entity overrides to detached comparisons.
Examples
Tests duplicate images in a `Set` and users loaded through separate persistence contexts.
What you can do after
Build it from scratch by implementing consistent `equals()` and `hashCode()` methods for value components and entities requiring detached equality.

Read how Java Persistence with Spring Data and Hibernate epub explains equality by value →

Kotlin in Action, 2E

equals is an object method that determines whether another value is equal to the receiver according to the object's equality contract.

How it is used
Compares Kotlin objects by their stored values through `==` and supports reliable use in hash-based containers.
How deep it goes
Explains manual `equals`, null handling, identity checks, `hashCode` consistency, and generated data-class equality; omits a complete manual hash-code implementation.
Examples
Uses `Customer` and `Point` instances, including equal field values, null comparison, a hash-set lookup, and a data-class declaration.
What you can do after
Apply it by choosing `==` for value comparison, `===` for identity, and data classes or matched `equals` and `hashCode` for value objects.

Read how Kotlin in Action, 2E explains equality by value →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.