Posted By:
Sean_Ruff
Posted On:
Thursday, October 27, 2005 09:14 PM
If you really don't want to use the instanceof operator you could create overloaded methods which take as a parameter your sub class, then use reflection to invoke said methods.
Method meth = this.getClass().getMethod("performLogic",new Class[]{superObject.getClass()});
meth.invoke(this,new Object[]{superObject});
Of course you'll want to do some validation, and you would define multiple overloaded "performLogic" methods which take subclasses of your superObject class type.