code: public static final Class<?> getComponentType(Object object) {
          Class<?> result = object.getClass().getComponentType();
          while (result.isArray()) {
              result = result.getComponentType();
          }
          return result;
      }
docs: Get component type of a (multidimensional) array or any other object.
  
  @param object Object (e.g. a multidimensional array).
  @return Component type (e.g. int, Boolean.class, String.class, double,
  etc.).