The following method is to implement toString
public String toString() {
return ReflectionToStringBuilder.toString(this);
}
How to understand the parameter this used by toString, what does it stand for here? Besides, why do we need to implement toString this way?
ReflectionToStringBuilderis a utility class used to generate theStringreturned when overridingObject#toStringusing the fields of the class instance passed as an argument.thishere refers to current instance of theObjectwhose fields are used to generate the returnedStringThe main advantage to using this class is that the
Stringdoes not have to be generated every time fields are added or removed.