null pointer exception on list.add
Posted
by
Eric
on Stack Overflow
See other posts from Stack Overflow
or by Eric
Published on 2011-03-08T00:05:01Z
Indexed on
2011/03/08
0:10 UTC
Read the original article
Hit count: 181
java
I've been working on this one error for a few hours so I thought I'd pick the brains of some pros.
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 {
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);
}
}
© Stack Overflow or respective owner