title: Want to use an array created in a method, for further use in another method
body: <p>I have a problem and the title actually sums it up perfectly. So i'll just go ahead and show you the code snippet.
  So the methode generate, is generating an array, that is filled with numbers between 1 and 1000, including both. The length of the array is user input.
  The next method, isPrime, is gonna conclude if its a prime number, so i can use those numbers with the true condition in another method. The generate method works but in isPrime i always get errors. If u can think of a better way, let me know please.</p>
  
  <pre><code>static int[] generate(int n) {
      int[] arr = new int[n+1];
      for(int x = 0; x &lt;= n; x ++) {
          int number = (int) (Math.random()* 999)+1;
          arr[x] = number;
      }
      return arr;
  }
  
  static int isPrime(int p, final int q[]) {                           
      boolean itIs = true;
      //final int[] arr;
  
      for(int r = 0; r &lt;= p; r++) {               // here it somehow states r is deadCode
          for(int j = 2; j &lt; q[r]; j++) {             
              if(q[r]%j == 0) {                       
                  itIs = false;                       
              }
          }
          return q[r];
      }
  
  }
  </code></pre>