Sufficient Method for Testing Equality
<p>I want to implement a custom <code>equals()</code> method for a class I have, <code>Board</code>. The method compares the arrays of each board, defined as <code>private int[] board</code>, returning true if the arrays are equal and false if they are not. I know there are some "gotchas" in testing equality, so I was wondering if the following code was optimal and sufficient for truly testing the equality: </p>

<pre><code>public boolean equals(Object y) {
    if (this.getClass() != y.getClass()) return false; //must be same class -- duh
    Board that = (Board) y; //y cast as Board
    int[] thisBoardCopy = this.getBoard(); //copy of current board
    int[] thatBoardCopy = that.getBoard(); //copy of y's board
    return Arrays.equals(thisBoardCopy, thatBoardCopy);
}
</code></pre>
