public class Position { int x, y; public Position(int x, int y) { this.x = x; this.y = y; } public boolean equals(Object o) { Position pos = (Position) o; return pos.x == this.x && pos.y == this.y; } }