Dear All
I have an array which holds method names and parameters as shown in array Functionstest. According to different conditions that happen in the program, my program will choose a specific row from array and build a string (like string1) that will be the method and parameters it needs to execute.
After building the string , how do I execute the related method ? For example, after building string2, how do I invoke the method plus1 that will actually execute it?
Thanks
Denis
public class TestClass {
public static void main(String[] args) throws Exception
{
Calling method solvethis(parameters)
}
public int solvethis (parameters) {
String Functionstest[][]= {
{"Mult1","Var1","Var2","Va
r3"},
{"Plus1","Var1","Var2"},
{"FindPrice","Var1","Var2"
,"Var3","V
ar4"},
{"FindCosine","Var1"}
};
// I go through each row of my array and make up a string like :
String1= "Mult1(Var1,Var2,Var3)"
String2="Plus1(Var1,Var2)"
String3="FindPrice(Var1,Va
r2,Var3,Va
r4)"
String4="FindCosine(Var1)"
}
// Methods that will carry out the different functions
public int Mult1(int Var1,int Var2, int Var3)
{
}
public int Plus1(int Var1,int Var2)
{
}
public int FindPrice1(int Var1,int Var2, int Var3, int Var4)
{
}
} // End class
Start Free Trial