我在modelData.add(i, es)
方法中獲得NullPointerException
。我從調試中知道es
不是null
。我真的很困惑,謝謝。list.add上的NullPointerException
public class EventTableModel extends AbstractTableModel {
//private int rowCount = 0;
protected List<EventSeat> modelData;
private static final int COLUMN_COUNT = 3;
private Event e;
Event j = GUIpos.m;
int i = 1;
public EventTableModel(Event e) {
this.e = e;
try {
System.out.println(modelData);
for (EventSeat es : e.getEventSeats()) {
modelData.add(i, es);
i++;
}
} catch (DataException ex) {
Logger.getLogger(EventTableModel.class.getName()).log(Level.SEVERE, null, ex);
}
}
哪裏'modelData'得到初始化? – 2011-03-08 00:07:16
'modelData' null? – 2011-03-08 00:07:44
'modelData'初始化在哪裏?不應該有'modelData = new ArrayList();'某處? –
srgerg
2011-03-08 00:09:02