我想在JTable中的列中找到值的总和.我已经使用getvalueAt方法从JTable中检索了值,但它最终没有找到值的总和.这是我的代码:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
for(int i = 0; i <model1.getRowCount(); i++) {
int total =0;
int Amount =Integer.parseInt(model1.getValueAt(i,3)+"");
total +=Amount;
System.out.println(total);
}
}
Run Code Online (Sandbox Code Playgroud)
我目前的输出是这样的:
10 // values in column
20
30
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
210 次 |
| 最近记录: |