@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
//返回所有字段
Field[] fields = this.getClass().getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
//当前字段名称
String name = fields[i].getName();
buffer.append(name);
buffer.append(":");
try {
//当前实例该字段值
buffer.append(fields[i].get(this));
} catch (Exception ex) {
System.out.println("err:" + ex.getMessage());
}
buffer.append("\n");
}
return buffer.toString();
}