0
  // store the class name in varibale className
    DataType className = ValueOfclassName;
    if(a instanceof className)
            {
                System.out.println("This is instance");
            }
Sumit Singh
  • 15,743
  • 6
  • 59
  • 89
ashish gupta
  • 135
  • 5
  • 16
  • Does this answer your question? [Java instanceof with class name](https://stackoverflow.com/questions/13873933/java-instanceof-with-class-name) – tobsob Jan 22 '20 at 06:12

1 Answers1

1

Well,instanceof is about Class, but class name is a String. You can learn more here.

Anyway, can this answer to your question?

A i = new A();
if (i instanceof A) {

}

if you want a String rapresentation of a class you can use:

A.class.getName()
Renato
  • 2,077
  • 1
  • 11
  • 22