【问题标题】:java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0java.lang.ArrayIndexOutOfBoundsException:数组索引超出范围:0
【发布时间】:2011-04-25 07:37:33
【问题描述】:

当我在这一行 .elementAt(spriteIdx); 上收到 ArrayIndexOutOfBoundsExceptions 时,试图找出这段代码是否出错。感谢您的提示。

杰森

Play = new Sprite[8][13];
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 13; j++) {
                int spriteIdx = map.getInt(String.format("play-%d-%d", i, j));
                if (spriteIdx != -1) {
                    Play[i][j] = (Sprite) savedSprites
                            .elementAt(spriteIdx);

【问题讨论】:

    标签: android arrays


    【解决方案1】:

    您似乎有空的saveSprites 数组。

    【讨论】:

    • 嗨,如果精灵是一个简单的检查条件! = 0 应该修复它吗?
    • if (sprites !=null && sprites.lenght > 0)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-16
    • 2012-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多