What I’m trying to do is execute a method in a class without knowing the method name. I have an array of methods from the class, and an index in of what method it is in the array, but not the actual method. This is what I attempted…but I don’t know how to actually do it.
Class blocks = Blocks.class;
Method[] methods = blocks.getDeclaredMethods();
Blocks block = new Blocks();
String a = block.(methods[blockBox.getSelectedIndex()]);
Is there anyway to do it? I also can’t rewrite my code to better suit this one situation.
For instance methods:
For static methods:
Provided that the methods have return type String and no parameters