Java ArrayIndexOutOfBound

后端 未结 4 700
感情败类
感情败类 2020-12-22 13:43

I am currently working on a student project and everytime I get this error: ArrayIndexOutOfBoundsException: 7. Can someone see where it occurs and how I can fix

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-22 14:42

    if(c >= Playerlist.length)
            {
                c = 0;
            }
            else
            {
                c++;
    
                //ARRAY_INDEX_OUT_OF_BOUNDS ERROR !!!!!!!!!!!!!!!!!!!!
                while(wuerfelsummen[c] == null)
    

    You are first checking if c is at most the last index of the array, and afterwards increment it by 1, possibly pushing it over that limit.

提交回复
热议问题