Hello,
Following is my Code.
public class ClearTech { String EmpCode = new String(); String EmpName; String Address; String DOB; double MonthlySalary; double MontlyTax; double NetSalary; byte NoOfDaysinMonth; byte NoOfLeaves; double NetPayableSalary; ClearTech() { EmpCode="Init Value"; EmpName = "Init Value"; Address = "Init Value"; DOB = "Init Value"; } public static void main(String[] args) { ClearTech CT = new ClearTech(); PerEmployee PE = CT.new PerEmployee(); PE.Accept(); PE.Display(); } class PerEmployee { int[] AnnualSalary = new int[3]; ClearTech[] CT = new ClearTech[3]; public void Accept() { CT[0].EmpCode = "E0001"; CT[0].EmpName = "Bob"; CT[0].Address = "E-12 Lajpat Nagar"; CT[0].DOB = "01/Feb/1974"; AnnualSalary[0] = 800000; CT[1].EmpCode = "E0002"; CT[1].EmpName = "Kevin"; CT[1].Address = "E-15 Mandir Marg"; CT[1].DOB = "01/Apr/1990"; AnnualSalary[1] = 1000000; CT[2].EmpCode = "E0003"; CT[2].EmpName = "Mohan"; CT[2].Address = "E-15 Mandir Marg"; CT[2].DOB = "31/July/1984"; AnnualSalary[2] = 400000; System.out.println("Done with Accept"); } public void Display() { System.out.println("Emp Code\tName\tAddress\t\tDate of Birth\tAnnual Basic Salary"); for(int i=1;i<4;i++) { System.out.println(CT[i].EmpCode+"\t"+CT[i].EmpName+"\t"+CT[i].Address+"\t"+CT[i].DOB+"\t"+AnnualSalary[i]); } } } class TempEmployee { int RatePerWorkingDay; } }
I am not able to figure out Why I am getting a Null pointer exception. I am new to this so please help as soon as possible as the deadline for my submission is 00:00 hours today (11th March 2012). Thanks in advance.