I know what a NullPointerException is and why it is thrown what is unclear to me is why it is thrown in my example since "a" is set to a new instance of my class in which the constructor of the class assigns a value to appointmentDate.
if(a==null){
return false;
}
if(a.getAppointmentDate().before(Calendar.getInstance())){
throw new InvalidCalendarException("date before now");
}
When executing this code a Nullpointer Exception is thrown in the second if-condition and I have no idea why since this point shouldn't be reached in cased a is null ( a is an instance of a class with a private java.util.Calendar attribute). In the constructor of said class the attribute is set according to input. Can someone please help me? I have been trying to get a solution for several hours now :(