title: How do I use reflection to invoke a method with parameters?
body: <p>Here is my class:</p>
  
  <pre><code>public class A{
      private void doIt(int[] X, int[] Y){
         //change the values in X and Y
      }
  }
  </code></pre>
  
  <p>I have another class that is trying to use <code>doIt</code> to modify two arrays. I have an error in my code but can't find it.</p>
  
  <pre><code>public class B{
    public void myStuff(){
      A myA = new A();
      int[] X = {1,2,3,4,5};
      int[] Y = {4,5,6,7,8,9};
      Method doIt = A.class.getDeclaredMethod("doIt",new Object[]{X,Y}); // error
      doIt.setAccessible(true);
      doIt.invoke(myA,new Object[]{X,Y});
    }
  }
  </code></pre>
  
  <p>Any help on how to fix method <code>myStuff</code>? </p>
  
  <p>If I use <code>getDeclaredMethod("doIt",new Object[]{X,Y});</code> the code does not compile. </p>
  
  <p>If instead I have <code>getDeclaredMethod("doIt",null);</code> then it says <code>NoSuchMethodException</code>.</p>