0
SalariedEmployee ppl1 = new SalariedEmployee("John","Smith","111-11-1111",800.00,new Date(07,23,2016));
//same code for ppl2, ppl3, ppl4

Employee [] employees=new Employee[4];
//Employee is an abstract class that is a parent for SalariedEmployee, etc
        employees[0]=ppl1;
        employees[1]=ppl2;
        employees[2]=ppl3;
        employees[3]=ppl4;

        if (employees[i].getBirthDate().getMonth() == 4){
              System.out.println("the line above gives me a NullPointerException");
}

I keep getting NullPointerException on the line

employees[i].getBirthDate().getMonth() == 4

Why am I getting this error and how can I fix it?

0 Answers0