java 循环 输出 Object键值

public class Demo {
    private Long id;
    private String name;
    private List<String>  format;
}

Demo demo = new Demo();
        demo.setFormat(list);
        demo.setName("xxxxxx");


         Object object =demo;
		 Field[] fields = object.getClass().getDeclaredFields();
        try {
            for (Field field : fields) {
                field.setAccessible(true);
                String name = field.getName();
                Object value = field.get(object);
                log.info(" key={}, value={}", name, value);
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

fox.风

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页