In accordance with the contract, the hashCode() method should return the same integer value ​​for two objects that are equal according to the equals() method. Is that true?
Explanation
Yes, if two objects are equal (equals() method returns true for them), the hashCode() method should return the same integer value for each of them. PS: According to the contract - "equal objects must have equal hash codes"

if we override method equals() for custom class so that it always returns true and create two instances of this class hashCode() returns different values for this two instances

2023 Feb 19, 3:25:04 PM

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты