Home > Net >  How can I compare data values while looping through my 3D array?
How can I compare data values while looping through my 3D array?

Time:02-10

I have this array where the first two 2d arrays are of n*n size, but the last array is a 2d array of size * 2. Essentially I need to compare the values of the first two arrays and compare them with the values of the smaller 2d array. I keep getting an out of bounds error?? The first two arrays values need to be compared with the values of the last array

       123  321    13
       231  132    21
       312  213    32
for (int i = 0; i < data.length; i  ) {
            for (int j = 0; j < data[i].length; j  ) {
                for (int k = 0; k < data[i][j].length; k  ) {
                    //I keep getting an out of bounds error here
                    if(data[i][j][k] < data[2][j][k]){
                        //do something
                    }
                }
            }
        }

CodePudding user response:

  •  Tags:  
  • Related