I have a baseclass, Statement
, which several other classes inherit from, named IfStatement
, WhereStatement
, etc... What is the best way t
if(object instanceof WhereStatement) {
WhereStatement where = (WhereStatement) object;
doSomething(where);
}
Note that code like this usually means that your base class is missing a polymorphic method. i.e. doSomething()
should be a method of Statement
, possibly abstract, that is overridden by sub-classes.