Array index out of bounds – How to check if it is out of bounds [closed]

Basically I’m trying to get it to not do what’s in the loop if it’s out of bounds. However, it still goes through the loop anyways. I’m not really sure how I’d do this correctly. Game is an array, and basically there’s a loop outside of this one that goes through all rows and collumns

if(row >= 0 && row < game.length)
{
    if(game[row - 1][col].equals("X"))
    {
        numNbrs += 1;
    }
}