[Solved] Where does the array get out of boundary in this code?


I would look at these lines here:

double xPoint[][][] = new double[value][fps][64];

//...

for (int j = 0; j < (44100 / fps); j += ((44100 / fps) / 64)) {
    xPoint[counter][i][j] = magnitude[counter][i][j];

Note that the inputted fps is 30, so ((44100 / 30) / 64)) = 22.96875 (or 22 as an int). So when this loop iterates, j will be as follows:

  • j = 0

  • j = 22

  • j = 44

  • j = 66 (Array out of bounds)

solved Where does the array get out of boundary in this code?