Fix the bug. Comparing objects

  • 6
  • Locked
Solution objects are not being compared correctly. Find the bug and fix it. The main method is not tested.
You can't complete this task, because you're not signed in.
Comments (2)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 37
23 June 2020, 15:25
This ask was fiddly as hell, wouldn't accept anything!
Level 23 , Phoenix, United States
2 February 2020, 00:38
Please explain why this is wrong,
if (o == this) return true;
if (o == null || !(o instanceof Solution)) return false;
and this is correct
if (o == this) return true;
if (o == null) return false;
if (!(o instanceof Solution)) return false;
I was failing the third condition, and this was the only thing I changed to make it pass. My first attempt was correct. I should not have had to change it to get this to pass.