Executing a method that takes a parameter of type (n-dimensional) array using reflection

Just specify Type[].class when looking up the method that has a parameter with a one-dimensional array of type Type.

Main.java:

import java.lang.reflect.*;
  
public class Main {
   public static void main(String args[]) {
      MyClass myClass = new MyClass();
  
      int []iArr = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
      String [][] sArr = {
         { "s1", "s2", "s3", "s4" },
         { "s5", "s6", "s7", "s8" }
      };
 
      try {
         Method m1 = MyClass.class.getMethod("myMethod1", new Class[] { int[].class });
         m1.invoke(myClass, new Object[] { iArr });
 
         Method m2 = MyClass.class.getMethod("myMethod2", new Class[] { String[][].class });
         m2.invoke(myClass, new Object[] { sArr }); 
      }
      catch(NoSuchMethodException e) {
         e.printStackTrace();
      }
      catch(IllegalAccessException e) {
         e.printStackTrace();
      }
      catch(InvocationTargetException e) {
         e.printStackTrace();
      }
   }
}
 
class MyClass
{
   public void myMethod1(int []iArr) {
      for (int i=0; i<iArr.length; i++)
         System.out.print(iArr[i] + " ");
      System.out.println();
   }
 
   public void myMethod2(String [][]sArr) {
      for (int i=0; i<sArr.length; i++) {
         for (int j=0; j<sArr[i].length; j++) {
            System.out.print(sArr[i][j] + " ");
         }
         System.out.println();
      }
   }
}