출처: http://stackoverflow.com/questions/160970/how-do-i-invoke-a-java-method-when-given-the-method-name-as-a-string

Java reflection API를 사용하면된다. 

Coding from the hip, it would be something like:

1
2
3
4
5
6
7
8
java.lang.reflect.Method method;
try {
    method = obj.getClass().getMethod(methodName, param1.class, param2.class, ..);
} catch (SecurityException e) {
    // ...
} catch (NoSuchMethodException e) {
    // ...
}
The parameters identify the very specific method you need (if there are several overloaded available, if the method has no arguments, only give methodName).

Then you invoke that method by calling

1
2
3
4
5
6
7
8
9
try {
    method.invoke(obj, arg1, arg2,...);
} catch (IllegalArgumentException e) {
    // ...
} catch (IllegalAccessException e) {
    // ...
} catch (InvocationTargetException e) {
    // ...
}
Again, leave out the arguments in .invoke, if you don't have any. But yeah. Read about Java Reflection