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

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -