title: java.lang.NullPointerException when accessing inner class field
body: <p>I am getting a null pointer exception from the code below at line 19,<code>seq[index].value = lo;</code>. The sequence class has a value field with integer type, but I think the problem is to access the array of seq instance.</p>
  
  <pre><code>public class ImprovedFibonacci {
  
  class Sequence{
      int value = 0;
      boolean isEven = false;
  }
  
  public static void main(String[] args){
  
      final int MAX_LOOP = 20;
      int lo = 1;
      int hi = 1;
      int i = 0;
      String mark = "-";
  
      int index = 0;
      ImprovedFibonacci.Sequence[] seq = new ImprovedFibonacci.Sequence[MAX_LOOP];
      seq[index].value = lo;
  
      System.out.println("Fibonacci seq 1 : " + lo);
      System.out.println("Sequence class index: "+index+"value: "+seq[index].value);
  
      for(i=MAX_LOOP;i&gt;=1;i--) {
          hi = hi + lo;
          lo = hi - lo;
          index++;
          if(hi % 2 == 0){
              mark = "-";
              seq[index].isEven = true;
          }else{
              mark = "";
          }
  
          System.out.println(i + " : " + hi + mark);
          seq[index].value = hi;
          System.out.println("Sequence class index: "+index+"value: "+seq[index].value+"IsEven: "+seq[index].isEven);
      }
  }
  }
  </code></pre>