Re: nullPointerException in abstract class



On Sep 29, 7:51 am, OldPro <rrossk...@xxxxxxxxxxxxx> wrote:
Why is this giving an error? birthDate is properly initialized, isn't
it?

public abstract class Employee
{
private String firstName;
private String lastName;
private String socialSecurityNumber;
private Date birthDate;

// three-argument constructor
public Employee( String first, String last, String ssn, String
birth )
{
firstName = first;
lastName = last;
socialSecurityNumber = ssn;
birthDate = new Date(); // Here is where the error occurs (it
doesn't stop the program)
birthDate.setDate(birth);
} // end three-argument Employee constructor

Please provide an SSCCE <http://physci.org/codes/sscce/>, so that we
can help you identify the real problem.

You might find the problem yourself in the process of creating the
SSCCE.

Good luck,
Daniel.

.



Relevant Pages

  • Re: inheritance question
    ... the constructor of the Employee class should accept all parameters ... public Employee (DateTime DOB, string Address, string MaritalStatus, ... > private string mMaritalStatus; ...
    (microsoft.public.dotnet.languages.csharp)
  • Problem with Datagrid and OOP
    ... I have two different objects Employee and SalaryType ... public int Add ... private string _code; ...
    (microsoft.public.dotnet.languages.csharp)
  • Problem with Datagrid and OOP
    ... I have two different objects Employee and SalaryType ... public int Add ... private string _code; ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Reflection in 1.1 and 2.0 - generic, fast copy delegate?
    ... Your delegate solution is is still significantly more efficient that reflection. ... Also you need permissions to emit code with the LCG version whereas using delegates does not appear to require permissions beyond those for public reflection and so you can have a fast solution even in low trust environments. ... private string _firstName; ...
    (microsoft.public.dotnet.framework.clr)
  • Re: EJB3 Newbie & Persistence
    ... private String name; ... CustomerCMP customer; ... public void setAddress{ ...
    (comp.lang.java.beans)