title: Java object Array
body: <p>I'm kind of new to Java and I've had trouble working with object arrays, the answer is probably pretty simple but I can't see it.</p>
  
  <p>I have a class named Vectors and a function named set_components()
  What I try to do is create an array of objects like this:</p>
  
  <pre><code>Vectors[] vec = new Vectors[2];
  </code></pre>
  
  <p>//Then access the function like this:</p>
  
  <pre><code>vec[0].set_components();
  </code></pre>
  
  <p>However I get this error: Exception in thread "main" java.lang.NullPointerException
  why is that?</p>
  
  <p>It works if I just do this for one object.</p>
  
  <pre><code>Vector vec = new Vector();
  vec.set_components();
  </code></pre>