- 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; } }
7 odpowiedzi
+ 9
What is not clear?
+ 9
! means not
+ 3
https://code.sololearn.com/cK2H7CdVEq45/?ref=app
In the comments you will find resources about the equals method.
+ 1
Else if(!name.equal.......
+ 1
@overide is not used then is are in problem
+ 1
What is not clear for you ?
+ 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