0

hey i want to invoke a Math class Method by String variable conatining a method name of Math class i have tested the below code:-

String spfunc="sin";
Method m=Math.class.getMethod(spfunc,double.class);
m.invoke(Math.class, 3.0);

but it resturns an error like this:-

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)

please help me out how to achieve this

Abhishek Kumar
  • 165
  • 1
  • 17

0 Answers0