Why do we need to override the method public boolean equals(Object ob) in any class?
Is public boolean equals(Object ob) is same as public boolean equals(Circle ob)?
Asked
Active
Viewed 107 times
-3

HACK
- 1
- 1
-
31. Well, you don't *have* to. 2. No, it's an *overload*. – MC Emperor Feb 15 '20 at 10:23
-
@Stefan: no, the default does not include "all attributes". The default implementation of equals and hashCode of `Object` perform an identity/reference comparison: two objects are only equal, if they point to the same location in memory. So `a = new Object(); b = new Object(); a != b;` (they are not equal), only `a = new Object(); b = a; a == b;` (same reference) – knittl Feb 15 '20 at 18:43
-
Thank you knittl, I deleted the wrong comment – Stefan Feb 15 '20 at 18:45