I am working on a Spring project wherein I have a POJO class
public class Owner extends Person {
private String address;
private String city;
private String telephone;
Getters and Setters
@Override
public String toString() {
return new ToStringCreator(this)
.append("id", this.getId())
.append("new", this.isNew())
.append("lastName", this.getLastName())
.append("firstName", this.getFirstName())
.append("address", this.address)
.append("city", this.city)
.append("telephone", this.telephone)
.toString();
}
}
- I have two doubts why a
toString()
method is being used here? What is its use? - What is ToStringCreator method doing?