How does JAVA find the parent class of a string from a string?

for example, the parent class of a normal class IOException is as follows:

Class<?> c = IOException.class;
System.out.println("IOException:"+c.getSuperclass());

but I implement this function: the IOException is saved as a string, and then how do I find the parent class of the class through that string? The last line of the following code indicates an error and cannot be implemented.

clipboard.png

for guidance, thank you!

Nov.10,2021

    Class<?> clazz = null;
    try {
      clazz = Class.forName("java.lang.Exception");
    } catch (ClassNotFoundException e) {
      System.err.println("can not load this class");
    }
    System.out.println(clazz.getSuperclass().getName());

Update:

public static String loadClass(String className) {
    Objects.requireNonNull(className);
    Class<?> clazz = null;
    try {
      clazz = Class.forName(className);
      return clazz.getSuperclass().getName();
    } catch (ClassNotFoundException e) {
      return "";
    }
  }

just do this:

System.out.println (Class.forName ("java.io.IOException"). GetSuperclass ());

)
Menu