Java: Getting the properties of a class to construct a string representation
问题 Let's say I have a class like this (and also further assume that all the private variables: public class Item { private String _id = null; private String _name = null; private String _description = null; ... } Now, if I want to build a toString() representation of this class, I would do something like this inside the Item class: @Override public String toString() { return (_id + " " + _name + " " + _description); } But what if I have say 15 private variables inside the class? Do I have to