Explain hashCode() and equals() contract.

Junior Java

Answer

If two objects are equal via equals(), their hashCode() must match.
Required for HashMap, HashSet, and other collections.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice