Making copies of Objects in Java
<p>I have this Java code:</p>

<pre><code>boolean[][] defaultBoard = {{false, false, false},
                            {false, false, false},
                            {false, false, false}};
Board board = new Board(defaultBoard);
Board nextBoard = new Board(defaultBoard);
nextBoard.getBoard()[1][5] = true;
board.printBoard();
</code></pre>

<p><code>printBoard</code>:</p>

<pre><code>public void printBoard() {
    for (boolean row[] : board) {
        for (boolean cell : row) {
            System.out.print( cell ? "#" : "." );
        }
        System.out.println();
    }
    System.out.println();
}
</code></pre>

<p>But it returns</p>

<pre><code>...
.#.
...
</code></pre>

<p>Which makes me think that <code>nextBoard</code> and <code>board</code> have got the same memory address. My question is: How do create a copy of <code>nextBoard</code> so that when <code>nextBoard</code> is edited, <code>board</code> isn't edited as well?</p>
