I have class AClass
and a method someMethod
that gets an Object
array as parameter.
public class AClass {
public void someMethod(Object[] parameters) {
}
}
In main, when I try to invoke this method on the the object that I have created and give an object array as a parameter to this method
Object[] parameters; // lets say this object array is null
Class class = Class.forName("AClass");
Object anObject = class.newInstance();
Method someMethod = class.getDeclaredMethod("someMethod", parameters.getClass());
someMethod.invoke(anObject, parameters);
I get "wrong number of arguments error". What am i missing?
See Question&Answers more detail:os