Android / Java rare and seemingly impossible exception causing force close
        Posted  
        
            by Guzba
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Guzba
        
        
        
        Published on 2010-04-19T04:37:11Z
        Indexed on 
            2010/04/19
            4:43 UTC
        
        
        Read the original article
        Hit count: 271
        
Hello all, I have an interesting problem being reported to me from an android application I have published. I have a two-dimensional array that I am iterating through using two for loops like so:
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, somehow arr[i][j] != 0 is throwing an ArrayIndexOutOfBoundsException. But very rarely. I have thousands of people use the app on a daily basis and get maybe twenty force close reports.
Is this something I can't avoid, maybe a problem with the phones memory, etc. or is there something I can do that I haven't thought of yet? Thanks.
© Stack Overflow or respective owner