I've got something along the lines of the following:
public class A { 
    public void theMethod(Object arg1) {
        // do some stuff with a single argument
    }
}
public class B {
    public void reflectingMethod(Object arg) {
        Method method = A.class.getMethod("theMethod", Object.class);
        method.invoke(new A(), arg);
    }
}
How do I modify that so that I can do the following instead?
public class A { 
    public void theMethod(Object... args) {
        // do some stuff with a list of arguments
    }
}
public class B {
    public void reflectingMethod(Object... args) {
        Method method = A.class.getMethod("theMethod", /* what goes here ? */);
        method.invoke(new A(), args);
    }
}
                A.class.getMethod("theMethod", Object[].class);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With