How to determine an object's class?

carrier picture carrier · Feb 12, 2009 · Viewed 647.3k times · Source

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 it is an instance?

Answer

IAdapter picture IAdapter · Feb 12, 2009
if (obj instanceof C) {
//your code
}