When can a == b be false and a.Equals(b) true?

后端 未结 7 1786
离开以前
离开以前 2021-02-01 04:59

I ran into this situation today. I have an object which I\'m testing for equality; the Create() method returns a subclass implementation of MyObject.

MyObject         


        
7条回答
  •  臣服心动
    2021-02-01 05:04

    In Java a ==b check if the references of the two objects are equals (rougly, if the two objects are the same object "aliased")

    a.equals(b) compare the values represented by the two objects.

提交回复
热议问题