title: java null pointer exception with static array
body: <p>I got a null pointer exception when accessing a static array from a static member method. 
  The exception is thrown when i call setData(x, y, z) from a thread. When I debugged it I found out data[0] is null when i try to write to it. I just don't understand how it can be null</p>
  
  <pre><code>public class dataContainer 
  {
      private static final short nrOfDataElements = ids.total_ids;
      private static regularDataElement[] data = new regularDataElement[nrOfDataElements];
  
  
      public static synchronized void getData(final short i, regularDataElement r)
      {
          if ( (i &gt;= 0) &amp;&amp; (i &lt; nrOfDataElements) )
              r.set(data[i].getTimestamp(), data[i].getValue());  
      }          
  
      public static synchronized void setData(short i, double ts, long val)
      {
          if ( (i &gt;= 0) &amp;&amp; (i &lt; nrOfDataElements) )
              data[i].set(ts, val); //&lt;&lt;-------null pointer exception, debugging showed data[i] == null, (with i = 0 and nrOfDataElements = 12)
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class regularDataElement 
  {
      regularDataElement()
      {
          set(0, 0);
      }
  
      public void set(double _ts, long _val)
      {
          System.out.println(this.ts + " " + _ts + " " + this.val + " " + _val); System.out.flush();
          this.ts = _ts;
          this.val = _val;    
      }
  
      public double getTimestamp()
      {
          return this.ts;
      }
  
      public long getValue()
      {
          return this.val;
      }
  
      private double ts;
      private long val;
  
  }
  </code></pre>