Laura Werner wrote:
It's weird behavior, but you have to be careful when changing it to instanceof. If an equals method tries to get too clever and suports equality with other types, you can end up with cases where equals is not symmetric, e.g. a.equals(b)==true but b.equals(a)==false. The usual "if (other instanceof <ThisClass>)" is usually safe, though.

Yes, this would indeed have been the case if Header implemented a different version of equals.


There's a good discussion of this in "Effective Java" by Josh Bloch. I think this book is a must-read for anyone doing API or class library development in Java.

Thanks for the hint. I have just ordered that book.


BTW, sorry I've been fairly scarce lately. I started a new job two weeks ago and I'm spending lots of time trying to get up to speed and figure out the environment here.

Hey, good luck at your new job! I hope you enjoy it there.


Odi


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to