Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@johnjohndoe
Created June 3, 2011 23:54
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 johnjohndoe/1007379 to your computer and use it in GitHub Desktop.
Save johnjohndoe/1007379 to your computer and use it in GitHub Desktop.
Java introspection for class name and function name
// Print name of the current function.
new Throwable().fillInStackTrace().getStackTrace()[0].getMethodName();
// Print simple class name.
getClass().getSimpleName();
// Print full class name.
getClass().getName();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment