samedi 3 octobre 2015

how do I retrieved field value from other java class?

Class<?> c = Class.forName("other");
Field[] field = c.getDeclaredFields();
System.out.println("name of field: "+fieldA[0].getName());

I can retrieved field name from other .java file but not the value.

Example:

 <other.java file>   public int namefield = 5;

from my main.java execute file I would like to retrieved the field name and the value.

display: name of field: namefield  value: 5 





Aucun commentaire:

Enregistrer un commentaire