小编use*_*592的帖子

Java ArrayIndexOutOfBoundsException:20个多维数组

我是一名新的程序员,我已经上了课,但还没有回到学校,所以当我有时间在projecteuler.net上解决问题时,我正试图自己取得成功.我已经在这个网站和谷歌搜索了解决方案,但他们所有的修复都使用了我多次检查的for循环中的错误变量.

例外:

线程"main"中的异常java.lang.ArrayIndexOutOfBoundsException:20 at Euler11.main(Euler11.java:37)

我的代码:

public class Euler11 {
    /**
     * @param args
     */
    public static void main(String[] args) {
        int[][] grid = new int[][] {
                {8, 02, 22, 97, 38, 15, 00, 40, 00, 75, 04, 05, 07, 78, 2, 12, 50, 77, 91, 8},
                {49, 49, 99, 40, 17, 81, 18, 57, 60, 87, 17, 40, 98, 43, 69, 48, 04, 56, 62, 00},
                {81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, …
Run Code Online (Sandbox Code Playgroud)

java multidimensional-array indexoutofboundsexception

1
推荐指数
1
解决办法
4591
查看次数