Question: Why do I get NullpointerException at public void update() method?, what can i do to fix this? public class CourseGrade implements Comparable { private Professor

Why do I get NullpointerException at public void update() method?, what can i do to fix this?

public class CourseGrade implements Comparable { private Professor professor; private Course course; private Map grades; private int numStudents;

public CourseGrade (Professor professor, Course course) { this.professor=professor; this.course=course; this.numStudents =0; Map grades = new HashMap<>(); } public void updateGrade (String grade, int numStudents) { if (grades.containsKey(grade)) { grades.put(grade, numStudents); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!