import java.lang.reflect.Field public <T> void set(){ List<T> list=new ArrayList<T>(); String name="",value=""; for(T t:list){ Class c = t.getClass(); Field[] fs = c.getDeclaredFields(); for(Field temp:fs){ try { temp.set(name, value); } catch (IllegalArgumentException | IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
时间: 2024-11-09 02:03:14