novicePrgrmr novicePrgrmr - 1 year ago 147
Java Question

NullPointerException on list.add

I am getting a null pointer exception at the modelData.add(i, es) method. I know from debugging that es isn't null. I'm really confused, thanks.

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 {
for (EventSeat es : e.getEventSeats()) {
modelData.add(i, es);
} catch (DataException ex) {
Logger.getLogger(EventTableModel.class.getName()).log(Level.SEVERE, null, ex);


Answer Source
protected List<EventSeat> modelData = new ArrayList<EventSeat>();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download