Equals richtig implementieren

class C { 
  final int x; final int y;
  C (int x, int y) { this.x = x; this.y = y; }
  int hashCode () { return this.x + 31 * this.y; }
}
nicht so:
  
  public boolean equals (C that) {
    return this.x == that.x && this.y == that.y;
  }



2010-02-04