Equals Methode für Objekte
Ich versuche, eine Equals-Methode für Objekte zu schreiben, die ihre Felder vergleicht und true zurückgibt, wenn sie gleich sind.
private int x, y, direction;
private Color color;
public boolean equals(Ghost other){
if (this.x == other.x && this.y == other.y &&
this.direction == other.direction && this.color == other.color)
return true;
else
return false;
}
Was könnte daran falsch sein?