我正在使用NullPointerException
该modelData.add(i, es)
方法。我从调试中知道es
不是null
。我真的很困惑,谢谢。
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);
}
}
您需要初始化一个List才能获取NullPointerException
。
protected List<EventSeat> modelData = new ArrayList<EventSeat>();