title: android, why say var is null
body: <p>I have a extended class, in class have a var, I define this by value, but say this is null !!!!</p>
  
  <pre><code>public class CalendarCell extends TextView
  {
  
      public static final String TAG = "CalendarCell";
  
      protected ArrayList&lt;Integer&gt; cellStates = new ArrayList&lt;&gt;();
  
  public CalendarCell(Context context)
  {
      super(context);
  }
  
  public CalendarCell(Context context, AttributeSet attrs)
  {
      super(context, attrs);
  }
  
  public CalendarCell(Context context, AttributeSet attrs, int defStyle)
  {
      super(context, attrs, defStyle);
  }
  
  @Override
  protected int[] onCreateDrawableState(int states)
  {
      int newStatesSize = cellStates.size();  // Error here (null)
      if (newStatesSize &gt; 0)
      {
  
          ...
      }
      else
      {
          return super.onCreateDrawableState(states);
      }
  }
  
  public void resetStates()
  {
      cellStates.clear();
  }
  
  public void addState(int state)
  {
      if(!cellStates.contains(state))
          cellStates.add(state);
      }
  }
  </code></pre>
  
  <p>I defined 'cellStates' by value.but say this is null. Why???</p>
  
  <pre><code>java.lang.NullPointerException
   at yaran.CalendarSection.ViewSection.CalendarCell.onCreateDrawableState(CalendarCell.java:44)
  </code></pre>