equals and hashCode
Equal objects must have equal hash codes — override both together.
Intermediate
Otherwise objects get lost in HashMap/HashSet. Use Objects.equals and Objects.hash, or records which generate both.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.