由于某种原因,我收到了java.lang.ArrayIndexOutOfBoundsException:7

时间:2018-11-24 19:54:42

标签: arrays

由于某种原因,我得到了java.lang.ArrayIndexOutOfBoundsException: 7

public void distance() {
    double velocity [] = {20,25,30,35,40,45,50};
    double angle [] = {25, 30,35,50,45,50,55};
    double [][] distance= new double[7][7];

    for (int i=0; i<7; i++)
    {
        for (int j=0;i<7; j++)
        {
            distance[i][j]= (Math.pow(velocity[i], 2) * Math.sin(2*angle[j]))/9.81;
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您的内部循环正在检查i < 7而不是j < 7