Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Object obj = Year.now(); // or any other class
- Class c = obj.getClass();
- Field[] fields = c.getDeclaredFields();
- for (Field f : fields) {
- try {
- System.out.println(f + " : " + f.get(obj));
- } catch (IllegalArgumentException ex) {
- System.out.println("Illegal argument " + f);
- } catch (IllegalAccessException ex) {
- System.out.println("Cannot access " + f);
- }
Advertisement
Add Comment
Please, Sign In to add comment