I got an application which should call different methods, based on the params' input. My idea until now is basically, that I create a Switch and call the methods separately by its case. Example:
switch (methodName)
{
case "method1":
method1();
break;
case "method2":
method2();
break;
default:
System.out.println(methodName + " is not a valid method!");
}
I was considering the option to invoke the method by its given string, as provided in this question:
How do I invoke a Java method when given the method name as a string?
But then I read from one of the answers, that it's not safe. What do you guys think?