Originally posted by P Moran:
Right now I want to simply create a generic toString override for my class, given I effectively want to just add a key value for every variable and print the variable
Of course that's still tedious.
If you want you can use reflection:
1) Without this check, your toString will always start with VType@abcdef123 or something similar.
2) Class.getDeclaredFields only returns the fields that are declared in the class itself, not those already declared in the super class. That's what getFields() is for.
3) field.get(this) is used to get the value of the field for the current instance.
Now be aware that this will include ALL fields. Using field.getModifiers() and the static methods in java.lang.reflect.Modifier you could filter out some, like static fields.