instanceof
shows if an instance is from class C or a subclass of C.
Is there a way to make sure that an instance is not a subclass?
In that case use getClass()
and compare it with the desired class:
boolean sameClass = someObject.getClass() == YourTargetClass.class;