java.lang.ArrayIndexOutOfBoundsException:数组索引超出范围:0
问题描述:
试图找出我是错误的这段代码,因为我收到此行上的ArrayIndexOutOfBoundsExceptions .elementAt(spriteIdx);
。谢谢你的提示。java.lang.ArrayIndexOutOfBoundsException:数组索引超出范围:0
杰森
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);
答
看来你有空saveSprites
阵列。
嗨,这么简单的chech条件,如果精灵! = 0应该修复它? – user652798 2011-04-25 17:16:20
if(sprites!= null && sprites.lenght> 0) – 2011-04-25 17:46:57
不要忘记这是和int null不会工作 – user652798 2011-04-25 19:47:33