casting - Why to cast a class to be compared before overriding equals()? -
so in code segment below, why cast "other" class explicitly after has passed equality test of getclass() results.
public boolean equals(object other) { . . . if (getclass() != other.getclass()) return false; person person = (person)other; . . . }
you can person.getteronperson()
when doing comparison. recall object class not contain necessary methods retrieve values want.
Comments
Post a Comment