Skip to content

Instantly share code, notes, and snippets.

@saniaky
Created August 29, 2015 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saniaky/1ca11904029a381f6397 to your computer and use it in GitHub Desktop.
Save saniaky/1ca11904029a381f6397 to your computer and use it in GitHub Desktop.
Java reflection api
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