Q:

java inheritance: distinguish between types of inherited classes

I have an Abstract class, called A, and two inherited classes: B and C. I have a method with a parameter:
myMethod (final A a)

and I´d like to make different things in case of the type of the instanciated object. How can I do it?
An good alternative is following another design pattern, but I am not allowed to change my code now.
Thanks.

A:

Use the instanceof keyword. For example:
if (a instanceof B) {...}
else if (a instanceof C) {...}
else {...}

