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
  • 34,719
  • 24
  • 185
  • 251
Milinda Bandara
  • 522
  • 8
  • 22

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,254
  • 20
  • 64
  • 106
Amol Binwade
  • 149
  • 6