manjo franko wrote:Thanks or the reply. I will implement a hash code. If i remove the equals method would it work? I still get a false. I would like to why is it so..
If you don't override both equals() and hashCode(), then it will inherit both those methods from the Object class. The Object class is designed to say that two instances are equal only if the references are pointing to the exact same instance. In other words, if the "==" comparison say that they are equal. Does that work? Well, is that what your application wants?
And by the way, the term "still get a false" is incorrect. With inheriting both equals and hashcode from the Object class, you will consistently get false. With your original program, the contract is broken, and you will get false most of the time. It is theoretically possible to get true -- although not very likely.
Henry