Auto-generating toString Method
- by Gordon
Is it good or bad practice auto-generating toString methods for some simple classes?
I was thinking of generating something like bellow where it takes the variable names and produces a toString method that prints the name followed by it's value.
private String name;
private int age;
private double height;
public String toString(){
Formatter formatter = new Formatter();
return formatter.format("Name: %s, Age: %d, Height %f", name, age, height).toString();
}