You can use the ReflectionAPI to achieve this. Just get all methodsthe method with this name from your desired class you wish to invoke(if available ) and compare theire namesinvoke it with your stringargs, in this case null.
BUT it's a bad design and you should rethink your application flow!
here is an example:
public class HelloWorld { public static void main(String[] args) { HelloWorld hello = new HelloWorld(); String[] calls = { "def", "abc", "ghi" }; try { Method[] methods = HelloWorld.class.getMethods(); for (String stringcall : calls) { for (Method method : methods) { if= (methodHelloWorld.getName()class.equalsIgnoreCasegetMethod(string))call, {null); method.invoke(hello, null); } } } } catch (Exception e) { // TODO: handle exception } } public void abc() { System.out.println("abc"); } public void def() { System.out.println("def"); } public void ghi() { System.out.println("ghi"); } }
BUT it's a bad design and you should rethink your application flow!