We are going to turn the problem around. As I see it, you do not need random numbers from 3 to 10. You ALWAYS need that sequence of numbers, but placed randomly within the 8x8 matrix.
What I would do, then, is a cycle that gives me the sequence of numbers from 3 to 10, and for each one, I generate a random position and, if it is not already occupied by another number, I assign it the value of the sequence. If you are already busy, I repeat the process until I find one that is not.
In code, it would be something like:
public static void main (String args[]) {
int FILAS = 8;
int COLUMNAS = 8;
int[][] matriz = new int[FILAS][COLUMNAS];
Random aleatorio = new Random();
boolean asignado;
for (int i = 3; i != 10; i++) {
asignado = false;
do {
int fila = aleatorio.nextInt(FILAS);
int columna = aleatorio.nextInt(COLUMNAS);
if (matriz[fila][columna] == 0) {
matriz[fila][columna] = i;
asignado = true;
}
} while (!asignado);
}
for (int i = 0; i < FILAS; i++) {
for (int j = 0; j < COLUMNAS; j++) {
System.out.print(matriz[i][j] + ", ");
}
System.out.print("\n");
}
}
What it produces for me, for example, is exit:
0, 9, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 4, 0, 0, 0, 0, 0, 0,
0, 5, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 7,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 3, 0, 0,
6, 0, 0, 8, 0, 0, 0, 0,