If class B
and class C
extend class A
and I have an object of type B
or C
, how can I determine of which type
You can use:
Object instance = new SomeClass();
instance.getClass().getName(); //will return the name (as String) (== "SomeClass")
instance.getClass(); //will return the SomeClass' Class object
HTH. But I think most of the time it is no good practice to use that for control flow or something similar...