First of all, I did research my issue on Stackoverflow and found an answer as to WHAT the NullPointerException is. However, I do not understand WHY I have a NullPointerException.
This code creates a simple grade tracking program. The following are data fields:
private String name;
private double[] testScores; //relevant to question  
private int x = 0;
private String answer;
private double testAverage;
private double tScore;//Relevant to question
So the Exception that I got occured when a Student object called this method. After I commented out the line with the array in the method definition, the Exception ceased to appear. I replaced the array with double tScore and the program started working fine. I do not understand why the use of an array gave me a NullPointerException. Please help me I am so confused by this issue. I tried to figure it out, but do not understand WHY this happened. Thanks for your help.
public void inputGrades()
  {
       Scanner gradeRead = new Scanner(System.in);
       System.out.println("Please Enter Student Grades.");
       do
       { 
           //testScores[x] = gradeRead.nextDouble(); ---Problem Line---
           tScore = (gradeRead.nextDouble());
           System.out.println("Are There Any More Grades? Enter y or n");
           answer = gradeRead.next();
           x++;
       }
       while(answer.equalsIgnoreCase("Y"));
  }
 
     
    