0

I need to get a retrun value from dynamically calling java class by passing a variable values to that calling method. I try to use the java.lang.reflect.Method;

PredictionManager pm = new PredictionManager();
Class invokeclass = pm.getClass();

Class[] cArg = new Class[1];
cArg[0] = Integer.class;//Instances.class;

Method lMethod = invokeclass.getMethod("showLong", cArg);
Object aaa= lMethod.invoke(pm, cArg);

in there I need to pass the value as a argument. but this method needs to give the parameter type. not the parameter value.

What can I do?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Milinda Bandara
  • 542
  • 8
  • 23

1 Answers1

6

in Method.invoke(...) you should not pass the parameter types, but the actual parameter values. Please check the java documentation for Method.invoke(...).

PM 77-1
  • 12,933
  • 21
  • 68
  • 111
AmolB
  • 149
  • 6