我一直得到NullPointerException

时间:2017-04-15 19:42:12

标签: java

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");
}

我一直在

行上获得NullPointerException

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

为什么我收到此错误,我该如何解决?

0 个答案:

没有答案