instanceof keyword usage
问题 Is using the instanceof keyword against the essence of object oriented programming ? I mean is it a bad programming practice? I read somewhere that using instanceof keyword means that the design may not be that good. Any better workaround? 回答1: Generally speaking yes. It's best to keep all code that depends on being a specific class within that class, and using instanceof generally means that you've put some code outside that class. Look at this very simple example: public class Animal { }