I'm trying to implement a constructor in Java and I don't know if I'm doing something wrong, but I keep getting garbage outputs.
This is the variable I'm trying to assign values to:
private static Employee employee;
This is how I'm trying to assign it:
employee = new Employee(empType, empFName, empLName, empBDate, empGender, empHireDate, empReleaseDate, empBaseSalary);
And here is the class and constructor:
public class Employee {
private String Type;
private String FName;
private String LName;
private Date BDate;
private String Gender;
private Date HireDate;
private Date ReleaseDate;
private double BaseSalary;
public Employee(String type, String fname, String lname, String bdate, String gender, String hire, String release, double salary){
this.Type = type;
this.FName = fname.toUpperCase();
this.LName = lname.toUpperCase();
this.BDate = new Date(bdate);
this.Gender = gender;
this.HireDate = new Date(hire);
if (release == "null"){
this.ReleaseDate = null;
}
else if(release != "null"){
this.ReleaseDate = new Date(release);
}
this.BaseSalary = salary;
}
}
When I try to print, just to test it, this is how I'm printing it:
System.out.println(employee);
And this is what I get every time:
Employee@4c264dd8
Could someone tell me what i'm doing wrong?