rt
------解决方案--------------------
用反射
import java.lang.reflect.Field;
。。。
public void printProperties(Object obj) throws IllegalAccessException {
Field[] fields = obj.getClass().getFields();
for (Field field: fields) {
String name = field.getName();
Object value = field.get(obj);
System.out.println( "field " + name + " 's vlaue is " + value);
}
}
------解决方案--------------------
楼上正解