Hi, sorry again for all the trouble, but I'm trying to get a reflective program to work. It takes a method from a user, and then runs it. My program works except it only works for strings. If they arguments needed for a method require ints or floats or whatnot, I can't run it.

The problem is because
getMethod(String name, Class[] parameterTypes) requires Classes
invoke(Object obj, Object[] args) requires objects. And I've tried for hours, but I can't get integers to turn into objects, or get the proper nomenclature (is that the right word?) for the integer class. Can anybody help me?

11 Years
Discussion Span
Last Post by jwenting

There are wrapper classes for every primitive type. Use those instead.

From the javadoc (which you DO you, do you?):

"Invokes the underlying method represented by this Method object, on the specified object with the specified parameters. Individual parameters are automatically unwrapped to match primitive formal parameters, and both primitive and reference parameters are subject to method invocation conversions as necessary. "

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.