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?

1

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.