我正在尝试获得系统的运行平衡。为此,我从 AMOUNT 列中获取 jtable 中所有数字的总和,然后将总和减去 txtLoanAmount 内的值。这是我的代码片段:
String LoanAmount = txtLoanAmount.getText();
float f = Float.valueOf(LoanAmount.trim()).floatValue();
float balance = 0;
float sum = 0;
for(int i=0;i<=tableLedger.getRowCount()-1;i++) {
sum = sum + Float.parseFloat(tableLedger.getModel().getValueAt(i, 2).toString());
}
balance = f - sum;
System.out.println(balance);
现在我收到错误消息:
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "20,475.00"
我该如何解决这个问题?任何帮助将不胜感激。谢谢