Easy way to override toString() in Java
java, overriding, tostring
Solution
I often use Apache Common Lang's `ToStringBuilder` like so:
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
This uses reflection to generate a `toString` for the object in question.
Problem
I have a java bean with many fields. I have know how to override `toString()` using StringBuilder and directly using field names. Is there any way to do it in better way like, without field names? Thanks in advance. P.S: this bean is already implemented in my product.