title: How to invoke method with variable arguments in java using reflection?
body: <p>I'm trying to invoke a method with variable arguments using java reflection. Here's the class which hosts the method:</p>
  
  <pre><code>public class TestClass {
  
  public void setParam(N ... n){
      System.out.println("Calling set param...");
  }
  </code></pre>
  
  <p>Here's the invoking code :</p>
  
  <pre><code>try {
          Class&lt;?&gt; c = Class.forName("com.test.reflection.TestClass");
          Method  method = c.getMethod ("setParam", com.test.reflection.N[].class);
          method.invoke(c, new com.test.reflection.N[]{});
  </code></pre>
  
  <p>I'm getting IllegalArgumentException in the form of "wrong number of arguments" at the last line where I'm calling invoke. Not sure what I'm doing wrong.</p>
  
  <p>Any pointers will be appreciated.</p>
  
  <ul>
  <li>Thanks</li>
  </ul>