Java 反射 遍历
通过Java的反射机制,获得到一个type为 java.util.List的field,如何对获得的list进行遍历?
例子如下:
Person bean:
class Person{ private String name; private List parents;...get(),set() }
public static void main(String[] args){ Person a = new person(); Class<?> progClass = bean1.getClass(); try { Field field = progClass.getDeclaredField("parents"); field.setAccessible("true"); } catch (Exception e){ e.printStackTrace(); }}