- 1

Explain me this code ????

@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Animal other = (Animal) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; return true; } }

20th Jul 2019, 1:21 PM
Sudhir Ghagare
Sudhir Ghagare - avatar
7 odpowiedzi
+ 9
What is not clear?
20th Jul 2019, 1:33 PM
Zhenis Otarbay
Zhenis Otarbay - avatar
+ 9
! means not
20th Jul 2019, 1:39 PM
Zhenis Otarbay
Zhenis Otarbay - avatar
+ 3
https://code.sololearn.com/cK2H7CdVEq45/?ref=app In the comments you will find resources about the equals method.
20th Jul 2019, 7:12 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Else if(!name.equal.......
20th Jul 2019, 1:36 PM
Sudhir Ghagare
Sudhir Ghagare - avatar
+ 1
@overide is not used then is are in problem
20th Jul 2019, 1:50 PM
Sudhir Ghagare
Sudhir Ghagare - avatar
+ 1
What is not clear for you ?
20th Jul 2019, 3:16 PM
Jameson LOUIS
Jameson LOUIS - avatar
+ 1
thisobj.equals(obj) method compare thisobj with obj. if it is same object -> end if obj is not null and has same class Animal or extended, and thisobj has stored name then can check if obj has stored same name
20th Jul 2019, 6:00 PM
zemiak