If I have an Employee class with a default constructor:
private String firstName;
public Employee(){}
and a setter:
Because the you want to set employee to the value of .setFirstName("John"); which does not return anything because it is a void
So you could either change your setter to:
public Employee setFirstName(String fname) {
this.firstName = fname;
return this;
}
OR Create a second constructor for Employee
public Employee(String fname){this.firstName = fname;}
Which would set firstname on init.