0

override equals

Is it correct that if i override equals in the subclass i need to use getClass instead of instanceof to keep the symetry? Are there othercases? Should i prefer all the time getClass() != obj.getClass() over this instanceof obj ?

19th Jan 2021, 5:02 PM
Manfred h
2 Respostas
0
This is difficult to answer without seeing the code, if your just extending a class overriding the method in parent should be fine.
19th Jan 2021, 6:52 PM
D_Stark
D_Stark - avatar
0
@D_Stark https://code.sololearn.com/ca0a2450a25A/# on oneside it gives me true but on the other false
19th Jan 2021, 7:24 PM
Manfred h