I have a baseclass, Statement
, which several other classes inherit from, named IfStatement
, WhereStatement
, etc... What is the best way t
The answer to your question is instanceof.
However, keep in mind that if your code needs instanceof, it's a sign that something is not right with your design. There are some cases when instanceof is justified, but they are rather exceptions. Usually, if your subclasses need to behave differently, you have to use polymorphism instead of if()s.