I am just curious to ask this, maybe it is quite meaningless.
When we are using instanceof in java, like:
if (a instanceof Parent){ //\"Parent\" here is
The static Parent.class
member is actually an object. You could assign it to a variable of type Object
or type Class
if you wanted to:
Object o = Parent.class;
Class c = Parent.class;
Parent
on the other hand isn't an object or a variable: it is a Type Name, as per the Java spec.
If you could do this...
a instanceof Parent.class
Since Parent.class
is an object then you could feasibly could also do this:
Cat myCat = new DomesticLonghair();
a instanceof myCat;
... which is just silly.