0
  // store the class name in varibale className
    DataType className = ValueOfclassName;
    if(a instanceof className)
            {
                System.out.println("This is instance");
            }
1

1 Answer 1

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()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.