I am looking at this question
How do I invoke a Java method when given the method name as a string?
and applying what the fist answer says
This is my code to call a method dyanmically, and its argument is an array of string
java.lang.reflect.Method method;
try {
String [] requiredParameters = testService.getRequiredParameters();
String [] parameters = new String[requiredParameters.length];
for (int i = 0; i<requiredParameters.length ; i++){
String valueRequiredParameter = request.getParameter(requiredParameters[i]);
parameters[i] = valueRequiredParameter;
}
method = new TestRecommendations().getClass().getMethod(service, parameters);
} catch (SecurityException e) {
// exception handling omitted for brevity
} catch (NoSuchMethodException e) {
// exception handling omitted for brevity
}
i get compiler error on the getMethod
states :
The method getMethod(String, Class<?>...) in the type Class<capture#1-of ? extends TestRecommendations> is not applicable for the arguments (String, String[])
And this is the type of method i want to call dynamcially
public ResultSet level0ForUser(String ... userURI) {