I have 3 classes for a project that I am working on. The first class I have no issues with. I am deriving a class from this method. I am in turn calling a method from this derived class into my main method. Specifically, I am getting an exception in thread "main", and I cannot invoke my hash map. If someone could help me, I would really appreciate it.
This is the code for the derived class:
import java.util.HashMap;
public class movieSchedule extends movieEvent {
private HashMap<String, String[]>movieTimes;
public movieSchedule() {
this.movieTimes = movieTimes;
}
public void AddMovieSchedule(String name, String[] times) {
movieTimes(name, times);
}
private void movieTimes(String name, String[] times) {
movieTimes.put(name, times);
}
}
This is the code for the relevant parts of the main method:
movieSchedule athensSchedule = new movieSchedule();
String[] guardiansTimes = {"5:30 P.M.", "7:20 P.M.", "9:00 P.M."};
athensSchedule.AddMovieSchedule("Guardians 4", guardiansTimes);
String[] airTimes = {"6:30 P.M.", "8:45 P.M.", "9:10 P.M."};
athensSchedule.AddMovieSchedule("AIR", airTimes);
String[] marioTimes = {"3:30 P.M.", "4:20 P.M.", "5:00 P.M."};
athensSchedule.AddMovieSchedule("Mario", marioTimes);
String[] oppenheimerTimes = {"7:30 P.M.", "9:20 P.M.", "10:00 P.M."};
athensSchedule.AddMovieSchedule("Oppenheimer", oppenheimerTimes);
String[] insidiousTimes = {"9:30 P.M.", "10:20 P.M.", "11:00 P.M."};
athensSchedule.AddMovieSchedule("Insidious", insidiousTimes);
This is the error I am getting:
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.util.HashMap.put(Object, Object)" because "this.movieTimes" is null