Created
July 15, 2016 23:14
-
-
Save JosiasSena/7280473ea01de6c0231e6c31483dda2c to your computer and use it in GitHub Desktop.
Reflection example in Java/Android
This file contains hidden or 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
// 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