我这里有个小问题..
for(int i=0; i<employee.length-1;i++){
if(employee[i].getID()==ID){
System.out.println("Employee Record for "+employee[i].getfName()+" "+employee[i].getlName()+" (ID#"+employee[i].getID()+"):\n"
+ "Basic Pay: "+employee[i].getSalary(0)+"\n"
+ "Housing Allowence: "+employee[i].getSalary(1)+"\n"
+ "Travel Allowence: "+employee[i].getSalary(2)+"\n"
+ "Net Salary : "+employee[i].getNetSalary()+"\n"
+ "Taxable : "+employee[i].getTaxable());break;}
if(i==employee.length-1){
System.out.println("EMPLOYEE NOT FOUND !!!");}
这是我通过 id 搜索员工的代码。我在运行时收到一条错误消息!这些值是由用户输入的,我对此没有问题
错误信息:
Exception in thread "main" java.lang.NullPointerException
at dd1318398p2.EmpRecord.searchEmpID(EmpRecord.java:103)
at dd1318398p2.EmpRecord.main(EmpRecord.java:37)
Java Result: 1
错误是指第一个 if 语句