waltermilner

Untitled

Sep 29th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1.     Object obj = Year.now(); // or any other class
  2.     Class c = obj.getClass();
  3.     Field[] fields = c.getDeclaredFields();
  4.     for (Field f : fields) {
  5.       try {
  6.         System.out.println(f + " : " + f.get(obj));
  7.       } catch (IllegalArgumentException ex) {
  8.         System.out.println("Illegal argument " + f);
  9.       } catch (IllegalAccessException ex) {
  10.         System.out.println("Cannot access " + f);
  11.       }
Advertisement
Add Comment
Please, Sign In to add comment