本文介绍了OutOfBoundException索引:1,大小:1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的出站异常索引为1,大小为1我似乎找不到问题这是我的代码:
i have an outofbound exception index 1, size 1 i cant seem to find the problem here is my code:
public void removeSpellToGraveyard(ArrayList<SpellCard> spells){
for(int c=0; c<5 ; c++ ){
SpellCard r = spells.get(c);
for(int i=0; i<5;i++){
if(spellArea.get(i) == r){
graveyard.add(spellArea.remove(i));
}
}
}
}
推荐答案
我将提供实现其明显意图的方法版本.我希望这不会帮助您解决问题,至少可以帮助您弄清楚自己想做的事情.
I'm going to provide a version of your method which achieves its apparent intent. My hope is that this will at least help you figure out what you wanted to do, if it doesn't solve your issue.
public void removeSpellToGraveyard(ArrayList<SpellCard> spells) {
for (SpellCard r: spells) {
if (spellArea.remove(r)) {
graveyard.add(r);
}
}
}
这篇关于OutOfBoundException索引:1,大小:1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!