Collections, Equality and Hashing | Java for Software Engineers | Episode 8
Description: A HashMap entry can still exist while lookup with its mutated key fails. Explore lists, sets, maps, equality and hashing, then build stable keys that preserve the collection's contract.
WHAT YOU'LL LEARN
- Choose list/set/map semantics deliberately.
- Explain equals/hashCode and collisions without confusing hashes with identity.
- Keep equality-relevant key state stable while a key is in a hash collection.
CHAPTERS
00:00 A map contains the entry, but lookup cannot find it
00:59 Choose a collection by the operations it promises
01:54 Reference identity and logical equality answer different questions
02:41 Read the deliberately mutable key
03:31 Reproduce the failed lookup and the stored value
04:22 Define a stable domain value for the repair
05:11 Equal keys find the same mapping
05:56 Equal hashes do not mean equal keys
06:45 The equals and hashCode promises work together
07:39 Correctness and performance are separate requirements
08:28 Ten checks cover semantics, boundaries and failure
09:23 Stable identities make collection behavior predictable
Java for Software Engineers | Episode 8: Collections, Equality and Hashing
Helpful background: Generics, immutable values and the distinction between an object reference and a value.
Next in this course: Episode 9 - SOLID in Practice: Improve a Design Under Change
Subscribe to Think Make Explore for practical Java tutorials and software design lessons.
Example notes: Bucket illustrations are conceptual, not measurements of JVM memory layout.
LEARNING REFERENCES
Java21 Object equality and hashCode contract: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Object.html
Java21 Map key mutation warning: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Map.html
Java21 HashMap: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/HashMap.html
#Java #JavaCollections #JavaTutorial Close description
WHAT YOU'LL LEARN
- Choose list/set/map semantics deliberately.
- Explain equals/hashCode and collisions without confusing hashes with identity.
- Keep equality-relevant key state stable while a key is in a hash collection.
CHAPTERS
00:00 A map contains the entry, but lookup cannot find it
00:59 Choose a collection by the operations it promises
01:54 Reference identity and logical equality answer different questions
02:41 Read the deliberately mutable key
03:31 Reproduce the failed lookup and the stored value
04:22 Define a stable domain value for the repair
05:11 Equal keys find the same mapping
05:56 Equal hashes do not mean equal keys
06:45 The equals and hashCode promises work together
07:39 Correctness and performance are separate requirements
08:28 Ten checks cover semantics, boundaries and failure
09:23 Stable identities make collection behavior predictable
Java for Software Engineers | Episode 8: Collections, Equality and Hashing
Helpful background: Generics, immutable values and the distinction between an object reference and a value.
Next in this course: Episode 9 - SOLID in Practice: Improve a Design Under Change
Subscribe to Think Make Explore for practical Java tutorials and software design lessons.
Example notes: Bucket illustrations are conceptual, not measurements of JVM memory layout.
LEARNING REFERENCES
Java21 Object equality and hashCode contract: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Object.html
Java21 Map key mutation warning: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Map.html
Java21 HashMap: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/HashMap.html
#Java #JavaCollections #JavaTutorial Close description
