Why this error

0

Can anyone please explain this error to me?

<%

    String[][] mesa = new String[30][30];

    out.println("");
    for(int i=30; i>=0; i--)
    {
        for(int n=0; n<((302)+1); n++)
        {
            out.print("-");
        }
        out.println("<br>");
        for(int j=0; j<30; j++)
        {
            mesa[i][j]=" ";
            out.print("|" + mesa[i][j]);
        }
        out.print("|<br>");
    }

    for(int n=0; n<((302)+1); n++)
    {
        out.print("-");
    }
    out.println("<br>");

%>

    
asked by anonymous 21.06.2017 / 05:23

1 answer

3

You have declared the table variable with 30 rows and columns, so the access range for this variable is 0 through 29, however in the loop "for (int i = 30; i > = 0; i--)", you access the variable at position 30 causing the exception, try changing the initialization from i to 29.

    
21.06.2017 / 07:06