If you want to implement a class that stores the first and last name of a person, you would normally implement something like this:
public class PersonMutable { private String firstName; private String lastName; private Date birthDate; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public Date getBirthDate() { return birthDate; } public void setBirthDate(Date birthDate) { this.birthDate = birthDate; } }
You can convert this class into an immutable class by following the rules explained earlier. The ...