Why can't I use the variable of type Class in the second argument of the instanceof operation? Example:
Class mClass= SomeClass.class; If(someObject instanceof mClass) Return; Ps I forgot to add that I need instanceof because in the condition it is expected that the heir of the specified class will also return true. Is this possible with a variable?
instanceofoperand checks whether an object belongs to the specified instance, not a variable / object. And you compare two objects. It is more correct to compareif(someObject instanceof SomeClass). - Rootware