Override the method toString in the class to produce the output you prefer, instead of the default value that Java automatically generates. Example:
public class User {
private String name;
...
@Override
public String toString() {
return name;
}
}
For complex objects, Apache Commons Lang provides some handy methods, if you are already using this dependency in your project:
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}