// store the class name in varibale className
DataType className = ValueOfclassName;
if(a instanceof className)
{
System.out.println("This is instance");
}
-
Does this answer your question? Java instanceof with class nametobsob– tobsob2020-01-22 06:12:13 +00:00Commented Jan 22, 2020 at 6:12
Add a comment
|
1 Answer
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()