title: Java, using an array of points
body: <p>I am writing a program in Java, in which I define a class</p>
  
  <pre><code>class Point
  {
      double x;
      double y;
  }
  </code></pre>
  
  <p>Then in a method, I define an array of points, as follows:</p>
  
  <pre><code>Point[]     line = new Point[6];
  </code></pre>
  
  <p>In the same method, I have the line</p>
  
  <pre><code>line[SampleSize - i + 1].x = i;
  </code></pre>
  
  <p>The first time this statement is hit, the value of its array index is 1;
  but the program throws a null pointer exception at this point.</p>
  
  <p>This would seem like the correct way to index the field of an object within an
  array of objects.  What am I doing wrong?</p>
  
  <p>Thanks in advance for any suggestions.</p>
  
  <p>John Doner</p>