Please someone explain me this statement using if conditionreturn this == obj? true : (theval%3 == 0 && ((GoodOne)obj).theval%3==0) ? true :false;

Thanx.
Moderator: admin
Please someone explain me this statement using if conditionreturn this == obj? true : (theval%3 == 0 && ((GoodOne)obj).theval%3==0) ? true :false;
Code: Select all
boolean temp = false;
if(this == obj)
{
temp = true;
}
else{
if(theval%3 == 0 && ((GoodOne)obj).theval%3==0) {
temp = true;
}else{
temp = false;
}
}
return temp;
Meaning that, according to the equal() method's individual properties - an equals() method that always returns false will not be a valid equals() method as it will not be reflexive and further to that - we won't be able to see the equal objects. However, according to the contract between the two methods - not the two method's individual properties - the only property of the contract that needs to be true is the one in the quote above. Meaning that equals() returning false should satisfy the question...If the equals() method returns true, the hashCode() of the two objects MUST be the same. The reverse is desirable but not necessary.
Users browsing this forum: No registered users and 6 guests