I read few stack overflow responses of questions similar to this but could not get satisfying answer. I want to create a generic method which accepts a graph object of type E. I want to pass this object alongwith a class name. In that method, I want to read an input from user and check if that is an instance of given class and throw some error message if it is not. I tried to use following code for the same:

```
public void readDependencyPair(Scanner scanner, String prompt, MyGraph<E> graph, String clazz) {
        System.out.println(prompt);
        Object obj = scanner.next();
        Class<?> c = Class.forName(clazz);
        if(obj instanceof c) {...
        }
}

```

The above code gives error at line "if obj is instance of c" saying "c cannot be resolved to a type. Create class 'c' or interface 'c' or enum 'c'".

I even tried to pass Class clazz instead of String parameter. And it still shows the same error that 'clazz' cannot be resolved to a type.