OutOfBoundException index:1, size:1

99封情书 提交于 2019-12-14 03:33:01

问题


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));

            }
        }
    }
}

回答1:


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);
        }
    }
}


来源:https://stackoverflow.com/questions/28888569/outofboundexception-index1-size1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!