title: How to add a variable to an array
body: <p>I am trying to set the value in an array to a variable. Here is my code:</p>
  
  <pre><code>//init the array as a float
  //I have tried to put a value in the brackets, but it returns a different error.
  //I initialized it this way so I could call it from other methods
  private float[] map;
  
  // generate a "seed" for the array between 0 and 255
  float x = generator.nextInt(256);
  int n = 1;
  // insert into the first 25 slots
  while(n &lt;= 25) {
      // here's my problem with this next line
      map[n] = x;
      double y = generator.nextGaussian();
      x = (float)Math.ceil(y);
      n = n + 1;
  }
  </code></pre>
  
  <p>I marked the line with my error, the error returned is: "uncaught exception thrown in...". What am I doing wrong??? Thanks in advance.</p>
  
  <p>EDIT-----</p>
  
  <p>Here's the whole exception:</p>
  
  <pre><code>    Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
  </code></pre>
  
  <p>I'm using y to generate a random gaussian, then converting it into a float value and changing x into that float value</p>
  
  <p>I'm pretty sure that It's that line, because that's what my compiler told me.</p>