Stephan van Hulst wrote:When asking questions about an exception, please post the full stack trace.
Campbell Ritchie wrote:Why have you got a List<String> instead of individual fields? You should have fields called name, address, etc., and maybe Name, Address, classes to encapsulate those data.
What does the documentation for List#set() say? Have you got at least enough elements in the List before you call set() to accommodate the indices you are setting?
Piet Souris wrote:Not only that, but if the first constructor is used before the second, then currentEmployee is null.
Piet Souris wrote:if you have this in main
you will get a NullPointerException.
A simple way to prevent that is to initialize the ArrayList right away by using:
I tried this and unfortunately it didn't help.
But a thing to ask yourself is:
Why would a class called 'NewEmployee' that, as Campbell writes, should contain fields like name, adress, function, et cetera, also contain a List of currentEmplyees, and even a List of Lists of currentEmployees?
Carey Brown wrote:
Carey Brown wrote:Just a reminder: it helps to periodically re-post your code in its current state so that we keep in sync with you and are not making comments on your prior posts that may no longer apply.
Carey Brown wrote:Instead of this, create a field 'hireDate' that is of type LocalDate and use these 3 parameters to construct the hireDate. There are lots of things that you can do with a LocalDate that are very difficult to do with just month/day/year, like compare two dates.
But you haven't got a separate input class. And I wouild interpret that bit about employee array as meaning that an employee has name, address, etc. fields.
Casey Jayne wrote:. . . the assignment is to use separate classes for the input . . . and then to store everything within an Employee array . . . .
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earthhttps://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter