-------------------------public class primes { // instance variables - replace the example below with your own private static int[] primes; private static int numPrimes; private static int ndx; private static int testPrime; /** * Constructor for objects of class primes */ public primes() { // initialise instance variables } /** * An example of a method - replace this comment with your own * * @param y a sample parameter for a method * @return the sum of x and y */ public static int getPrime(int whichPrime) { int[] primes = new int[whichPrime]; while (numPrimes < whichPrime) { for (ndx = 0; ndx < numPrimes && testPrime % primes[ndx] != 0; ndx++ { ; } if(ndx == numPrimes) { primes[numPrimes++] = testPrime; } testPrime++; } return primes[whichPrime]; } }

import java.util.Scanner; public class PrimeFinder extends primes { static public void main (String[] args) { Scanner input = new Scanner(System.in); int whichPrime; int finalprime; System.out.print("Enter which prime you want: "); whichPrime = input.nextInt(); finalprime = getPrime(whichPrime); System.out.println("The #" + whichPrime + " prime is" + finalprime); } }

-----------

error:

Exception in thread "main" java.lang.NullPointerException

at primes.getPrime(primes.java:40)

at PrimeFinder.main(PrimeFinder.java:21)