not that familiar with JAVA or exception handling. Looking for some advice on what is acceptable and what is frowned upon.
The scenario, i'm building a game of life program, I have conditionals set up to check if a cell will be out of bounds and not try to access that 'cell'. My question is, is it acceptable to use a try catch block instead of 8 conditionals, and just do nothing if the arrayOutOfBounds exception is thrown. ie ignore the cells out of bounds, or is this bad practice? for instance...
try{
neighbors += cellIsAlive(row, col);
}catch(ArrayIndexOutofBoundsException e)
{
//dont do anything and continue counting neighbors
}
In this scenario cellIsAlive method checks a location in a multi dimensional array and returns 1 if it's alive 0 otherwise and throws ArrayIndexOutofBoundsException.
Is this a good idea or is it bad practice to use exceptions this way?
Thanks ahead of time for any input.