Compare two objects with .equals() and == operator

前端 未结 15 1206
礼貌的吻别
礼貌的吻别 2020-11-22 01:13

I constructed a class with one String field. Then I created two objects and I have to compare them using == operator and .equals() too

15条回答
  •  隐瞒了意图╮
    2020-11-22 01:38

    Statements a == object2 and a.equals(object2) both will always return false because a is a string while object2 is an instance of MyClass

提交回复
热议问题