My code is now correct but i want to ask something

if (row == board.length-1 && col == board.length) {
for (int i = 0; i < board.length; i++) {
for (int j = 0; j < board.length; j++) {
System.out.print(board[i][j] + " ");
}
System.out.println();
}
return;
}

if i write this :-
if (row == board.length-1 && col == board.length)
then my code gives right output but i think col == board.length goes to index 9 this should gives ArrayIndex exception

and if i write this :-
if (row == board.length-1 && col == board.length-1)
then my code gives wrong output why ? according to me condition is right i think because col is in the range of 0 to 9-1 which is 8

Please help me in this

@nigamshubham1998,
I see that you have got the correct answer. Do you have any further doubts on this question?