请帮我纠正我的if语句。我正在尝试浏览arraylist元素,但在某些情况下,next和previous按钮会显示命令行错误。错误不同,但它们有以下共同的...Java arraylist导航
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index....
继承人的代码
public class buttonListener implements ActionListener {
public void actionPerformed(ActionEvent x){
if (x.getSource() == nxtButton){
indexCounter++;
balanceFrame.setVisible(false);
callDetail();
if(indexCounter == filePaths.size()-1) { //max counter...we dont want to exceed the max number, size of array
indexCounter = -1;
}
}
else if (x.getSource() == prevButton){
indexCounter--;
balanceFrame.setVisible(false);
callDetail();
if(indexCounter == 0){
indexCounter = filePaths.size()-1;
}
}
}}
请发布完整的堆栈跟踪。 – adarshr 2012-01-06 09:19:13
您需要发布callDetail()方法并完成堆栈跟踪。 – Manish 2012-01-06 09:19:32
您不显示使用索引访问列表的代码,并且不显示堆栈跟踪。该消息甚至不完整。阅读堆栈跟踪:它有你需要知道问题发生的所有信息。 – 2012-01-06 09:20:25