title: using class as array in another class
body: <p>I am trying to do the following</p>
  
  <p>1 - I need to create a class like this</p>
  
  <pre><code>public class base {
      int a;
      String b;
      public base() {
        a = 0;
        b = "";
      }
  }
  </code></pre>
  
  <p>2 - I need to create a class that creates an array of "base" and sets some values</p>
  
  <pre><code>public class arrayBase {
      public base[] ab = new base[2];    
      public arrayBase() {  
         ab[0].a = 1;
         ab[0].b = "test1";
         ab[1].a = 2;
         ab[1].b = "test2";       
      }
  }
  </code></pre>
  
  <p>3 - I need to use "arrayBase" in another class</p>
  
  <pre><code>public class test{
      public static void main(String[] args) {
         arrayBase p = new arrayBase();
         System.out.println(p.ab[0].a);
      }
  }
  </code></pre>
  
  <p>When I try this it gives an error</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException.
  </code></pre>
  
  <p>How can I solve that problem?</p>