Search code examples
matrixindexoutofboundsexception

Is there a way to force java to ignore an Index out of bounds exception


If, say, I want to iterate through a matrix and check the contents at the positions around the one I'm at, is there a way to check all those positions, and should one or more of them be out of bounds, it just skips that part and moves on?


Solution

  • I don't think it's advisable for most situations, in fact it is known to be bad Java practice, but you can use try and do nothing about exceptions.

    The whole issue with doing this though, is you can find yourself stuck trying to determine what an error is for eons of time and it turns out being something you could have handled with catch