How do I iterate over an Array field reflectively?

Posted by kunjaan on Stack Overflow See other posts from Stack Overflow or by kunjaan
Published on 2010-05-31T06:41:38Z Indexed on 2010/05/31 6:52 UTC
Read the original article Hit count: 128

Filed under:
|
|

I have

Class<? extends Object> class1 = obj.getClass();
    Field[] fields = class1.getDeclaredFields();
    for (Field aField : fields) {
      aField.setAccessible(true);
      if (!Modifier.isStatic(aField.getModifiers()) && Modifier.isPublic((aField.getModifiers()))) {
       if (aField.getType().isArray()) {
          for (?? vals : aField) {
            System.out.println(vals);
          }
        }
      }
    }

© Stack Overflow or respective owner

Related posts about java

Related posts about reflection