當我嘗試從表中添加列時,它們會給我那個錯誤。線程「AWT-EventQueue-0」中的異常java.lang.NullPointerException
private void SAVEALLActionPerformed(java.awt.event.ActionEvent evt)
{
model=(DefaultTableModel)tblCont.getModel();
int col=tblCont.getColumnCount();
String[]field=new String[col-2];
String[]value=new String[col-2];
field[0]="ID";
field[col-3]="Total";
int pop=1;
for (int i = 3; i < col-1; i++) {
field[pop]=String.valueOf(tblCont.getColumnName(i));
pop++;
}
try {
for(int i=0;i<tblCont.getRowCount();i++){
int opo=1;
int test=0; int tes=0;
value[0]=String.valueOf(model.getValueAt(i, 0));
for (int j = 3; j < col-1; j++) {
value[opo]=String.valueOf(model.getValueAt(i, j));
//Here points my error
tes =tes + Integer.parseInt(value[pop].trim());
test=test+tes;
opo++;
}
String tet = Integer.toString(test);
value[col-4]=tet;
JOptionPane.showMessageDialog(this, tet);
UpdateRec(field, value, "contribution");
}
} catch (SQLException e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
TableClearCont();
ShowContFile();
}
方法名稱不應以大寫字母開頭。你是否甚至從Java API開始看到一個大寫字母的方法?遵循Java約定! – camickr
對不起,我仍然是一名學生,但無論如何感謝提醒 –