fork download
  1. import java.lang.reflect.*;
  2.  
  3. public class Main{
  4.  
  5. public static class Test{
  6. public int x, y, z;
  7. }
  8.  
  9. public static void main(String args[]) throws Exception{
  10. Test instance = new Test();
  11. instance.x = 10;
  12. instance.y = 20;
  13. instance.z = 30;
  14. for(final Field f : Test.class.getFields())
  15. System.out.printf("Test.%s = %d\n", f.getName(), f.getInt(instance));
  16. }
  17. }
Success #stdin #stdout 0.08s 380224KB
stdin
Standard input is empty
stdout
Test.x = 10
Test.y = 20
Test.z = 30