java便利实体类

    技术2022-07-15  85

    public class test { public static void main(String[] args) throws Exception{ User e = new User(); reflect(e); } public static void reflect(User e) throws Exception{ Class cls = e.getClass(); Field[] fields = cls.getDeclaredFields(); for(int i=0; i<fields.length; i++){ Field f = fields[i]; f.setAccessible(true); System.out.println("属性名:" + f.getName() + " 属性值:" + f.get(e)); } } }

     

    Processed: 0.013, SQL: 9