NullPointerException on list.add

前端 未结 3 691
广开言路
广开言路 2021-01-01 11:10

I am getting a NullPointerException at the modelData.add(i, es) method. I know from debugging that es isn\'t null. I\'m r

相关标签:
3条回答
  • 2021-01-01 11:25

    Try

    protected List<EventSeat> modelData = new ArrayList<EventSeat>(); 
    
    0 讨论(0)
  • 2021-01-01 11:28

    On the first look, seems like modelData has not been instantiated. I would instantiate the modelData like:

    protected List<EventSeat> modelData = new ArrayList<EventSeat>();
    

    FYI.. In Java 7 there will be a new syntax you can use- someObject?.doSomething();

    0 讨论(0)
  • 2021-01-01 11:36

    You need to initialize a List to not get the NullPointerException.

    protected List<EventSeat> modelData = new ArrayList<EventSeat>();
    
    0 讨论(0)
提交回复
热议问题