title: I keep getting java.lang.ArrayIndexOutOfBoundsException: 500
body: <p>I keep getting an error that the array is out of bounds and I can't figure out what is wrong.</p>
  
  <pre><code>    int[] oddArray = new int[500];//holds all the odd numbers
      int[] primeArray = new int[500];//holds all the prime numbers
      int[] modArray = new int[500];//holds all the mod values
      int remainder, p = 0, x = 0;        
  
      //fills up the oddArray &amp; modArray
      for(int n = 0; n &lt; 500; n++)
      { 
          oddArray[n] = (n * 2) + 1;
          modArray[n] = (n* 2) + 1;
      }
  
      for(int i = 0; i  &lt; 500; i++)
      {
  
          //finds prime numbers
          for(int n = 0 ; n &lt; 500; n++)
          {   
              //divides the odd numbers by the current mod value
              remainder = oddArray[n] % modArray[x]; 
  
              //if remainder is not 0 it will place a value in prime array
              if(remainder != 0)
              {
                   primeArray[p] = oddArray[n];
                   p++; 
              }
          }
  
          //prints out list of odds/mod/and primes side by side
          System.out.println(oddArray[i] + " | " + modArray[i] + " | " + primeArray[p]);
          ++x;
      }
  </code></pre>
  
  <p>This is the error code </p>
  
  <blockquote>
    <p>1 | 1 | 0</p>
    
    <p>3 | 3 | 0</p>
    
    <p>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 500
       at projectprime_v1.ProjectPrime_V1.main(ProjectPrime_V1.java:41)
       Java Result: 1
       BUILD SUCCESSFUL (total time: 0 seconds)</p>
  </blockquote>