Sridhar Iyer wrote:But I don't understand why is it behaving differently for different values.
What different values? All we can go by is what you've posted, and the results seem perfectly reasonable to me if you look at Gaurangkumar's post.
The fact is,
you should NEVER use '==' to compare
objects. ALWAYS, ALWAYS, ALWAYS use
equals(),
(was that loud enough?)
[Edit] I should probably add that the
reason is that if the class doesn't have an
equals() method, it will use
Object's, which works exactly like '=='.
If it
does define one (and if you ever write one),
the very first statement in it should be:
Winston