Comparing objects never returns true

后端 未结 4 1878
死守一世寂寞
死守一世寂寞 2021-01-25 20:35

I\'m trying to compare two objects of the same type (in method doesHave), but I\'ve never got \"true\" returned. Here\'s my code:

private ArrayList          


        
4条回答
  •  迷失自我
    2021-01-25 21:27

    Right now your code checks if the memory address of two objects is the same which can only be true if it is the same exact object.

    You need to implement a method that compares two Osoba objects by comparing whichever properties you want from these objects and returning true/false appropriately.

提交回复
热议问题