Jose Aguilar wrote:. . . . comparing objects with == can give back some wrong answers . . . .
No, == always gives the correct answer, but to
the wrong question. If you ask the wrong question, the answer given will not tell you what you need to know. If somebody asks me at 10pm whether I
like coffee, the answer is yes. They would then be surprised if I don't drink the coffee they gave me. It is because they asked the wrong question; they should have asked whether I
would like some coffee, to which the answer would be, no thank you, it will stop me sleeping.
Asking whether x == y may get the answer no when you actually wanted the answer to whether x.equals(y) which is yes.