I have a method which returns a multi-dimensional array (always two dimensions, but variable in size). I need to loop through every element to check for the existence of a condition.
Normally in a single dimension array, I would use something like:
for(int i = 0; i < array_name.length; i++) { //Do stuff here }
I notice that the two dimensional array has a length, but I am not sure which length it is returning.
Does anyone have any code snippets for looping through every element in a two dimensional array? I was thinking of using a try-catch block for each dimension to catch each "OutOfArrayIndex" errors, but was thinking that there had to be an easier way.