public static int dimension(Class clazz) {
        checkArrayType(clazz);

        int result = 0;
        while (clazz.isArray()) {
            result++;
            clazz = clazz.getComponentType();
        }

        return result;
    }
public static int dimension ( Class clazz ) { checkArrayType ( clazz ) ; int result = 0 ; while ( clazz . isArray ( ) ) { result ++ ; clazz = clazz . getComponentType ( ) ; } return result ; }
Calculate the dimension of array

@param clazz the type of array
@return the dimension of array