i have a 2-dimensional array of ints which i'm looping over. i want to check if an array's element i'm pointing at is within the bounds of that array. say, if i had an array of size 3x2, i would like to be able to do this:
for(int i=some_variable;i<arrayWidth;i++) {
for (int j=other_variable;j<arrayHeight;j++) {
if (!array[i][j].ISOUTOFBOUNDS) {
// do something
}
}
}
is there an eloquent way of achieving that or should i just check the indices manually?
ps. i and j can turn out to be negative, too, so i would like to check that as well.
intyou probably want to use>and<