I'm having some issues with entering data into my array. The first run through the loop has no issues...that I can see, but once I have entered the first batch of information I start getting Null Pointer Exception errors. Here is the exact error:
"Exception in thread "main" java.lang.NullPointerException at Employee.main(Employee.java:108)"
On the second run through the loop, if I try to add a second set of data, the NPE is on line 108. If I try to view the data it's on line 112. I can't figure out what variable is being considered null. Can anyone help?
public static void main(String[] args) { Scanner input = new Scanner(System.in); final int size = 100; //max array size int numEmployee=0; //number of array entries int i; int choice=0; Employee [] employeeData = new Employee[size]; //an array of objects employeeData[numEmployee] = new Employee(); System.out.println("1. Enter new employee data"); System.out.println("2. Display employee data"); System.out.print("3. Quit \n=> "); choice = input.nextInt(); while(choice!=3){ if(choice == 1){ employeeData[numEmployee].setFirstName(); //******line 108 NPE is here****** numEmployee++; }else if(choice == 2){ for(i = 0; i<numEmployee; i++); System.out.println(employeeData[i].getFirstName()); //******line 112 NPE is here****** }else{ System.out.println("Invalid entry. Please try again."); } //close if System.out.println("1. Enter new employee data"); System.out.println("2. Display employee data"); System.out.print("3. Quit \n=> "); choice = input.nextInt(); } //close while System.out.println("You have quit."); } //close main