I have an algorithm to generate a solved Sudoku board. In my tests I want to check whether two subsequent calls to the fillBoard() method, generate a different board, with this code:
SudokuBoard sb = new SudokuBoard();
sb.fillBoard();
int [][] board1 = sb.getBoard();
sb.fillBoard();
int [][] board2 = sb.getBoard();
int same = 0;
for(int i = 0; i < 9; i++)
{
for(int y = 0; y < 9; y++)
{
if(board1[i][y] == board2[i][y])
same++;
}
}
assertTrue(same < 10);
When I assign sb.getBoard() to board2, board1 changes as well. How can that be solved?