I try to display all values of objects from List using reflection technique, i tried but failed... I only managed to display values for a single object
public class Reflection {
public static void retrieveProperties(Object object) {
for (Field field : object.getClass().getDeclaredFields()) {
field.setAccessible(true);
Object value;
try {
value = field.get(object);
System.out.println(field.getName() + "=" + value);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire