When to use identity comparison instead of equals?
- by maaartinus
I wonder why would anybody want to use identity comparison for fields in equals, like here (Java syntax):
class C {
private A a;
public boolean equals(Object other) {
// standard boring prelude
if (other==this) return true;
if (other==null) return false;
if (other.getClass() != this.getClass()) return…