code: public static <T> T createObject(Class<T> clazz, Object... constructorArgs) {
          if(constructorArgs == null) return createObject(clazz);
  
          T object;
  
          Class[] parameterTypes = new Class[constructorArgs.length];
  
          for (int i = 0; i < constructorArgs.length; i++) {
              parameterTypes[i] = constructorArgs[i].getClass();
          }
  
          try {
              Constructor ctor = clazz.getConstructor(parameterTypes);
              object = (T)ctor.newInstance(constructorArgs);
          } catch (Exception e) {
              throw new RuntimeException(e);
          }
  
          return object;
      }
docs: Create an empty object of the given class.
  @param clazz
  @param constructorArgs arguments to pass to the matching constructor
  @param <T>
  @return