Created
October 22, 2013 15:11
-
-
Save nkonev/7102445 to your computer and use it in GitHub Desktop.
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
| import java.lang.reflect.Method; | |
| // http://www.quizful.net/post/java-reflection-api | |
| public class ReflectionMath{ | |
| public static double reflectCall(String func, Object... args) throws Exception{ | |
| Method[] methods = Math.class.getMethods(); | |
| for(Method method: methods){ | |
| String name = method.getName(); | |
| if(name.equals(func)){ | |
| Double d = (Double) method.invoke(Math.class, args); | |
| return d; | |
| } | |
| } | |
| throw new Exception("Not found Math."+func); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment