Android / Java is a rare and seemingly impossible exception that causes closing force

I have an interesting issue being reported to me from the Android application that I posted. I have a two-dimensional array, which I repeat using two for such loops:

for (int i = 0; i < arr.length; ++i)
{
    for (int j = 0; j < arr[i].length; ++j)
    {
        if (arr[i][j] != 0)
            // does stuff
    }
}

The problem is that somehow arr [i] [j]! = 0 throws an ArrayIndexOutOfBoundsException. But very seldom. I have thousands of users using the app every day and receive perhaps twenty strong private reports.

I canโ€™t avoid this, maybe there is a problem with the memory of phones, etc., or is there something I can do that I havenโ€™t thought about yet? Thank.

+3
source share
1

, , , . , ; .

array[i] = new Whatever[array[i].length - 1];
+7

Source: https://habr.com/ru/post/1741718/


All Articles