public int getSum(){
int sum=0;
for(int i=1; i <= sqlite_master.getRowCount(); i++)
{
sum=sum+Integer.parseInt((String) sqlite_master.getValueAt(i, 2));
}
return sum;
}
的代码被写入,以便获得一个特定列的总和在2列的表与一个列字符串和其他数字数组索引越界异常的JTable中
错误是
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 2 >= 2
at java.util.Vector.elementAt(Vector.java:474)
请提供一些解决方案以解决问题
指数从0开始在Java中。不在1.为什么你将整数存储为字符串,而不是将它们存储为整数? –