After validation, program is running successfully and storing the user input into last_name variable. But when I am trying to put last_name in the student Array, it gives me a null-pointer exception.If I omit the third line inside the for loop, the program is running fine. Here, "setStudentLastName" is a void method inside the Student class that accepts a string parameter
//Create a array using the data from user
Student student[] = new Student[numOfStudents];
for(int i=0;i<student.length;i++)
{
int j = i+1;
last_name = Validator.validUpperCase(sc,"Enter student "+j+" last Name: ");
student[i].setStudentLastName(last_name);
}