To get the number of dimensions : Multidimensional Arrays « Collections « Java Tutorial






public class Main {
  public static void main(String args[]) {
    String[][] data = new String[3][4];
    System.out.println(getDimension(data));
  }

  public static int getDimension(Object array) {
    int dim = 0;
    Class c = array.getClass();
    while (c.isArray()) {
      c = c.getComponentType();
      dim++;
    }
    return (dim);
  }
}
//2








9.4.Multidimensional Arrays
9.4.1.Initialize a two-dimensional array in matrix
9.4.2.Arrays of Arrays
9.4.3.Arrays of Arrays in Varying Length
9.4.4.Defining Multidimensional Arrays
9.4.5.Array Of int Arrays
9.4.6.Get array upperbound
9.4.7.To get the number of dimensions
9.4.8.Array Of string Arrays