I have something like the following:
public class A {
public void theMethod(Object arg1) {
}
}
public class B {
public void reflectingMethod(Object arg) {
Method method = A.class.getMethod("theMethod", Object.class);
method.invoke(new A(), arg);
}
}
How can I change this so that I can do the following instead?
public class A {
public void theMethod(Object... args) {
}
}
public class B {
public void reflectingMethod(Object... args) {
Method method = A.class.getMethod("theMethod", );
method.invoke(new A(), args);
}
}
source
share