Author Topic:   equals
posted February 19, 2000 07:38 PM           
For equals to work should both objects be of same type???
why is Equals on wrapper class always giving --false
Is it i did'nt try any correct examples are my
Question is wrong

maha anna
posted February 19, 2000 08:54 PM             
whenever you get doubts like this you refer to JDK API Doc.
From the API for the Wrapper classes(Boolean/Byte/Integer..)
public boolean equals(Object obj)
Compares this object to the specified object.
obj - the object to compare with
true if the objects are the same; false otherwise.
equals in class Object

Tony Alicea
posted February 20, 2000 08:20 AM             
When you override equals you define the term of equality although I am not sure you should be careless since I understand that certain rules like of associativity, commutativity etc. should also be met.

maha anna
posted February 20, 2000 11:59 AM             
Tony has got a point. It we OVERRIDE the .equals(Object o) method then we have define the hashCode() also. This method should return the same value for objects that compare equality using this equals(Object o) method.
maha anna

Tony Alicea
posted February 20, 2000 12:39 PM             
Thanks maha anna; I forgot about the part of the hashCode()!