code: public static <T> T createObject(Class<T> clazz) {
          T object;
  
          try {
              object = clazz.newInstance();
          } catch (InstantiationException e) {
              throw new RuntimeException(e);
          } catch (IllegalAccessException e) {
              throw new RuntimeException(e);
          }
  
          return object;
      }
docs: Create an empty object of the given class.
  @throws RuntimeException if object could not be created.
  @param clazz
  @param <T>
  @return