I am working on a project where I have a class named dBase with getter and setter methods for fields such as first and last names. However, When I run the code, line 6 of the code portion is highlighted with a java.lang.NullPointerException error, which doesn't help me at all.
How do I make this work? Thanks, in advance
case 3:
input.nextLine();
for (int i = 0; i < num; i++){
System.out.println("Enter first name of student " + (i + 1));
String firstN = input.nextLine();
roster[i].setfName(firstN);
System.out.println("Enter last name of student " + (i + 1));
String lastN = input.nextLine();
roster[i].setlName(lastN);
}
break;