嘿我想通过字符串变量调用 Math类方法,包含方法名称 Math class 我测试了下面的代码: -
String spfunc="sin";
Method m=Math.class.getMethod(spfunc,double.class);
m.invoke(Math.class, 3.0);
但它会重现这样的错误: -
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at EquationSolver.solveEquation(EquationSolver.java:112)
at EquationSolver.substituteValue(EquationSolver.java:94)
at EquationSolver.main(EquationSolver.java:20)
请帮我解决如何实现这个目标