获取类的字段值

public static String findAllInClassFieldsName(Class l) {
String[] fieldStr = null;
if (l != null) {
Field[] fields = l.getDeclaredFields();
fieldStr = new String[fields.length];
for (int i = 0; i < fields.length; i++) {
fieldStr[i] = fields[i].getName();
}
}
String fields = Arrays.toString(fieldStr);
fields = fields.substring(1, fields.length() - 1);
return fields;

}
posted @ 2019-07-06 14:45  zzl0916  阅读(279)  评论(0编辑  收藏  举报