title: Quick Fix Java Error ArrayIndexOutOfBoundsException
body: <p>Am I just to blind to see the solution? </p>
  
  <pre><code>sampleSum = 0;
  for(int x : sampleWeights)
     sampleSum += x;
  
  population = new int[sampleSum];
  int z = 0;
  
  for(int i = 0; i &lt; nsamples; i++)
  for(int j = 0; j &lt; sampleWeights[i]; j++) 
  {
      population[z] = i;
      z++;
  }  
  </code></pre>
  
  <p>Any help is appreciated! Thanks!</p>