Skip to content

Instantly share code, notes, and snippets.

@JosiasSena
Created July 15, 2016 23:14
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 JosiasSena/7280473ea01de6c0231e6c31483dda2c to your computer and use it in GitHub Desktop.
Save JosiasSena/7280473ea01de6c0231e6c31483dda2c to your computer and use it in GitHub Desktop.
Reflection example in Java/Android
// without reflection
ClassName className = new ClassName();
className.unsubscribe();
// with reflection
Object className = ClassName.class.newInstance();
Method m = className.getClass().getDeclaredMethod("unsubscribe", new Class[0]);
m.invoke(className);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment