If you try to check if a give string (for example: "java.lang.String") represents the valid name of a class in the class loader you could use Class.forName(className). Something like in this example:
public class Demo {
public static void main(String[] args) {
System.out.println(isInstance("java.lang.String")); // will print true
System.out.println(isInstance("Longssss")); // will print false
}
public static boolean isInstance(String string) {
try {
return Class.forName(string).getName().equals("java.lang.String");
} catch (Exception e) {
return false;
}
}
}
You will have to explore the Class.forName method