I have a created a class that creates an instance of an object
public class EmployeeProfile {
/////////INSTANCE VARIABLES/////////
private static String fName;
private static String lName;
private static String email;
private static String phone;
////////CONSTRUCTORS////////////
public EmployeeProfile()
{
}
public EmployeeProfile(String firstName, String lastName, String emailAdd, String pNumber)
{
fName = firstName;
lName = lastName;
email = emailAdd;
phone = pNumber;
}
}
When I call the empty constructor and populate it myself with the methods I've created everything is fine. However when I call a new object with a new name using the second constructor and the parameters, they overwrite the data from the first object!!
EmployeeProfile prof1 = new EmployeeProfile();
prof1.firstName("John");
prof1.lastName("Doe");
prof1.email("[email protected]");
prof1.phone("555-555-5555");
EmployeeProfile prof2 = new EmployeeProfile("Jane", "Doe", "[email protected]", "555-123-4567");
System.out.println(prof1.getProfile());
System.out.println(prof2.getProfile());
When I run this prof1 and prof2 both return the data from prof2. What am I doing wrong here?
staticmeans?