Комментарии:
How deal with a method with empty parameters
Ответитьimport java.util.*;
import java.lang.reflect;
class invokeOperation{
public static void main(String args[]){
invokeOperation io = new invokeOperation();
final String[] OPERATION_LIST = {"add","sub","div","cos" };
String condition = getCondition();
for (String op : OPERATION_LIST) {
if (condition.equals(op)){
io.getClass().getMethod(op).invoke(this);
}else{
break;
}
}
public String getCondition(){
return "add";
}
}
}
Thank you so much! I was struggling for so long trying to do this, and you explained it beautifully in just 5 min
Ответитьhow to pass multiple parameters for the method here?
Ответить