Created
August 29, 2015 19:42
-
-
Save saniaky/1ca11904029a381f6397 to your computer and use it in GitHub Desktop.
Java reflection api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void getObject(Object obj) { | |
try { | |
for (Field field : obj.getClass().getDeclaredFields()) { | |
//field.setAccessible(true); // if you want to modify private fields | |
System.out.println(field.getName() | |
+ " - " + field.getType() | |
+ " - " + field.get(obj)); | |
} | |
} catch (IllegalAccessException e) { | |
e.printStackTrace(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment